changeset 25532:1311aee85dcf

revsetbenchmarks: ensure all indexes have the same width This avoids an alignment glitch.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 11 Jun 2015 10:55:02 -0700
parents 371d8afc9144
children 4bdf6f58aee1
files contrib/revsetbenchmarks.py
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/revsetbenchmarks.py	Tue Jun 09 16:57:18 2015 -0700
+++ b/contrib/revsetbenchmarks.py	Thu Jun 11 10:55:02 2015 -0700
@@ -92,9 +92,22 @@
     check_call(['hg', 'log', '--rev', str(rev), '--template',
                '{desc|firstline}\n'])
 
+def idxwidth(nbidx):
+    """return the max width of number used for index
+
+    Yes, this is basically a log10."""
+    nbidx -= 1 # starts at 0
+    idxwidth = 0
+    while nbidx:
+        idxwidth += 1
+        nbidx //= 10
+    if not idxwidth:
+        idxwidth = 1
+    return idxwidth
+
 def printresult(idx, data, maxidx):
     """print a line of result to stdout"""
-    mask = '%i) %s'
+    mask = '%%0%ii) %%s' % idxwidth(maxidx)
 
     out = ("wall %f comb %f user %f sys %f (best of %d)"
            % (data['wall'], data['comb'], data['user'],