From faa02fd2b6bdfc7c41b71ef6635314e23b19d50f Mon Sep 17 00:00:00 2001 From: Guillaume Chazarain Date: Sat, 29 Aug 2009 14:36:37 +0200 Subject: [PATCH] Optimization: call getpriority() instead of reading /proc --- iotop/ioprio.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iotop/ioprio.py b/iotop/ioprio.py index d1162a8..40a4dbf 100644 --- a/iotop/ioprio.py +++ b/iotop/ioprio.py @@ -50,9 +50,12 @@ def ioprio_data(ioprio): sched_getscheduler = ctypes_handle.sched_getscheduler SCHED_OTHER, SCHED_FIFO, SCHED_RR, SCHED_BATCH, SCHED_ISO, SCHED_IDLE = range(6) +getpriority = ctypes_handle.getpriority +PRIO_PROCESS = 0 + def get_ioprio_from_sched(pid): scheduler = sched_getscheduler(pid) - nice = int(open('/proc/%d/stat' % pid).read().split()[18]) + nice = getpriority(PRIO_PROCESS, pid) ioprio_nice = (nice + 20) / 5 if scheduler in (SCHED_FIFO, SCHED_RR): -- 2.11.4.GIT