summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2012-06-13 16:12:42 +0200
committerJohannes Weiner <hannes@cmpxchg.org>2012-06-13 16:20:39 +0200
commitea97ff997c659fa5d19a222ba3352c2e97931d1a (patch)
treeef7c41b633a44894bac1970a8998e8964e5b29be
parent1f526ad520db8dcafd4e8e29130b182c450f5cf5 (diff)
runtest: log real, user, sys times as dict
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
-rw-r--r--examples/time.spec12
-rwxr-xr-xruntest15
2 files changed, 19 insertions, 8 deletions
diff --git a/examples/time.spec b/examples/time.spec
index 573aabd..f20c70d 100644
--- a/examples/time.spec
+++ b/examples/time.spec
@@ -1,7 +1,13 @@
# Parse the timestamps that runtest writes to the .time files
%data time
-read(name + '.time')
+readdict(name + '.time')
-%item Walltime
-mean(merge(fold(time[0])))
+%item Real time
+mean(merge(time['real']))
+
+%item User time
+mean(merge(time['user']))
+
+%item System time
+mean(merge(time['sys']))
diff --git a/runtest b/runtest
index 33fd3d1..827eb3b 100755
--- a/runtest
+++ b/runtest
@@ -44,8 +44,13 @@ class Work(object):
self.data.close()
print('', file=self.log)
self.log.close()
- def timestamp(self):
- print(monotonic_time(), file=self.data)
+ def clock_start(self):
+ self.start_date = monotonic_time()
+ def clock_stop(self, rusage):
+ end_date = monotonic_time()
+ print('real', end_date - self.start_date, file=self.data)
+ print('user', rusage.ru_utime, file=self.data)
+ print('sys', rusage.ru_stime, file=self.data)
class Monitor(object):
def __init__(self, prefix, name, execute):
@@ -145,12 +150,12 @@ noreap = []
for w in works.values():
sub = subprocess.Popen(w.execute, shell=True,
stdout=w.log, stderr=w.log)
- w.timestamp()
+ w.clock_start()
workers[sub.pid] = w
noreap.append(sub)
while workers:
try:
- pid, status = os.wait()
+ pid, status, rusage = os.wait3(0)
except OSError, e:
if e.errno == errno.ECHILD:
print('warning: os.wait() missed children!')
@@ -164,7 +169,7 @@ while workers:
sys.exit(1)
if pid in workers:
w = workers.pop(pid)
- w.timestamp()
+ w.clock_stop(rusage)
if not args.oneshot:
signal.setitimer(signal.ITIMER_REAL, 0.0, 0.0)