Mercurial > public > mercurial-scm > hg
comparison contrib/revsetbenchmarks.py @ 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 |
comparison
equal
deleted
inserted
replaced
25531:371d8afc9144 | 25532:1311aee85dcf |
---|---|
90 sys.stdout.write("Revision: ") | 90 sys.stdout.write("Revision: ") |
91 sys.stdout.flush() | 91 sys.stdout.flush() |
92 check_call(['hg', 'log', '--rev', str(rev), '--template', | 92 check_call(['hg', 'log', '--rev', str(rev), '--template', |
93 '{desc|firstline}\n']) | 93 '{desc|firstline}\n']) |
94 | 94 |
95 def idxwidth(nbidx): | |
96 """return the max width of number used for index | |
97 | |
98 Yes, this is basically a log10.""" | |
99 nbidx -= 1 # starts at 0 | |
100 idxwidth = 0 | |
101 while nbidx: | |
102 idxwidth += 1 | |
103 nbidx //= 10 | |
104 if not idxwidth: | |
105 idxwidth = 1 | |
106 return idxwidth | |
107 | |
95 def printresult(idx, data, maxidx): | 108 def printresult(idx, data, maxidx): |
96 """print a line of result to stdout""" | 109 """print a line of result to stdout""" |
97 mask = '%i) %s' | 110 mask = '%%0%ii) %%s' % idxwidth(maxidx) |
98 | 111 |
99 out = ("wall %f comb %f user %f sys %f (best of %d)" | 112 out = ("wall %f comb %f user %f sys %f (best of %d)" |
100 % (data['wall'], data['comb'], data['user'], | 113 % (data['wall'], data['comb'], data['user'], |
101 data['sys'], data['count'])) | 114 data['sys'], data['count'])) |
102 | 115 |