From: Avery Pennarun Date: Thu, 26 Aug 2010 03:06:16 +0000 (-0700) Subject: cmd/memtest: print per-cycle and total times. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=baa7e474bedb61a4752afe5acfe30cd365062927;p=packages%2Fb%2Fbup.git cmd/memtest: print per-cycle and total times. This makes it easier to compare output from other people or between machines, and also gives a clue as to swappiness. Signed-off-by: Avery Pennarun --- diff --git a/cmd/memtest-cmd.py b/cmd/memtest-cmd.py index 745550c..faad3f0 100755 --- a/cmd/memtest-cmd.py +++ b/cmd/memtest-cmd.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -import sys, re, struct, mmap +import sys, re, struct, mmap, time from bup import git, options from bup.helpers import * @@ -10,19 +10,25 @@ def s_from_bytes(bytes): return ''.join(clist) +last = start = 0 def report(count): - fields = ['VmSize', 'VmRSS', 'VmData', 'VmStk'] + global last, start + fields = ['VmSize', 'VmRSS', 'VmData', 'VmStk', 'ms'] d = {} for line in open('/proc/self/status').readlines(): l = re.split(r':\s*', line.strip(), 1) d[l[0]] = l[1] + now = time.time() + d['ms'] = int((now - last) * 1000) if count >= 0: e1 = count fields = [d[k] for k in fields] else: e1 = '' + start = now print ('%9s ' + ('%10s ' * len(fields))) % tuple([e1] + fields) sys.stdout.flush() + last = time.time() optspec = """ @@ -61,3 +67,5 @@ for c in xrange(opt.cycles): #print bin.encode('hex') m.exists(bin) report((c+1)*opt.number) + +print 'Total time: %.3fs' % (time.time() - start)