]> arthur.barton.de Git - bup.git/commitdiff
cmd/memtest: print per-cycle and total times.
authorAvery Pennarun <apenwarr@gmail.com>
Thu, 26 Aug 2010 03:06:16 +0000 (20:06 -0700)
committerAvery Pennarun <apenwarr@gmail.com>
Thu, 26 Aug 2010 03:07:08 +0000 (20:07 -0700)
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 <apenwarr@gmail.com>
cmd/memtest-cmd.py

index 745550c3cd483f397ba029669c63a63f305acaf4..faad3f0b0d259096cc974f18e0dae20d62e54c46 100755 (executable)
@@ -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)