revsetbenchmarks: use a more compact output format with a header
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 09 Jun 2015 17:15:48 -0700
changeset 25534 43e5a6819aba
parent 25533 4bdf6f58aee1
child 25535 6d1e456645c9
revsetbenchmarks: use a more compact output format with a header We change the output from: revset #0: draft() 0) wall 0.011989 comb 0.010000 user 0.000000 sys 0.010000 (best of 177) 1) wall 0.012226 comb 0.010000 user 0.000000 sys 0.010000 (best of 193) 2) wall 0.011838 comb 0.020000 user 0.000000 sys 0.020000 (best of 208) to: revset #0: draft() wall comb user sys count 0) 0.012028 0.010000 0.000000 0.010000 170 1) 0.012218 0.010000 0.000000 0.010000 157 2) 0.012622 0.010000 0.000000 0.010000 189 This opens the road to more useful output.
contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py	Fri Jun 12 16:42:07 2015 -0400
+++ b/contrib/revsetbenchmarks.py	Tue Jun 09 17:15:48 2015 -0700
@@ -111,12 +111,23 @@
 def printresult(idx, data, maxidx):
     """print a line of result to stdout"""
     mask = '%%0%ii) %%s' % idxwidth(maxidx)
+    out = ['%10.6f' % data['wall'],
+           '%10.6f' % data['comb'],
+           '%10.6f' % data['user'],
+           '%10.6f' % data['sys'],
+           '%6d'    % data['count'],
+          ]
+    print mask % (idx, ' '.join(out))
 
-    out = ("wall %f comb %f user %f sys %f (best of %d)"
-           % (data['wall'], data['comb'], data['user'],
-              data['sys'], data['count']))
-
-    print mask % (idx, out)
+def printheader(maxidx):
+    header = [' ' * (idxwidth(maxidx) + 1),
+              '  %-8s' % 'wall',
+              '  %-8s' % 'comb',
+              '  %-8s' % 'user',
+              '  %-8s' % 'sys',
+              '%6s' % 'count',
+             ]
+    print ' '.join(header)
 
 def getrevs(spec):
     """get the list of rev matched by a revset"""
@@ -172,6 +183,7 @@
     update(r)
     res = []
     results.append(res)
+    printheader(len(revsets))
     for idx, rset in enumerate(revsets):
         data = perf(rset, target=options.repo)
         res.append(data)
@@ -198,6 +210,7 @@
 for ridx, rset in enumerate(revsets):
 
     print "revset #%i: %s" % (ridx, rset)
+    printheader(len(results))
     for idx, data in enumerate(results):
         printresult(idx, data[ridx], len(results))
     print