Mercurial > hg
comparison contrib/revsetbenchmarks.py @ 25534:43e5a6819aba
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 09 Jun 2015 17:15:48 -0700 |
parents | 4bdf6f58aee1 |
children | 6d1e456645c9 |
comparison
equal
deleted
inserted
replaced
25533:4bdf6f58aee1 | 25534:43e5a6819aba |
---|---|
109 return idxwidth | 109 return idxwidth |
110 | 110 |
111 def printresult(idx, data, maxidx): | 111 def printresult(idx, data, maxidx): |
112 """print a line of result to stdout""" | 112 """print a line of result to stdout""" |
113 mask = '%%0%ii) %%s' % idxwidth(maxidx) | 113 mask = '%%0%ii) %%s' % idxwidth(maxidx) |
114 | 114 out = ['%10.6f' % data['wall'], |
115 out = ("wall %f comb %f user %f sys %f (best of %d)" | 115 '%10.6f' % data['comb'], |
116 % (data['wall'], data['comb'], data['user'], | 116 '%10.6f' % data['user'], |
117 data['sys'], data['count'])) | 117 '%10.6f' % data['sys'], |
118 | 118 '%6d' % data['count'], |
119 print mask % (idx, out) | 119 ] |
120 print mask % (idx, ' '.join(out)) | |
121 | |
122 def printheader(maxidx): | |
123 header = [' ' * (idxwidth(maxidx) + 1), | |
124 ' %-8s' % 'wall', | |
125 ' %-8s' % 'comb', | |
126 ' %-8s' % 'user', | |
127 ' %-8s' % 'sys', | |
128 '%6s' % 'count', | |
129 ] | |
130 print ' '.join(header) | |
120 | 131 |
121 def getrevs(spec): | 132 def getrevs(spec): |
122 """get the list of rev matched by a revset""" | 133 """get the list of rev matched by a revset""" |
123 try: | 134 try: |
124 out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) | 135 out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) |
170 printrevision(r) | 181 printrevision(r) |
171 print "----------------------------" | 182 print "----------------------------" |
172 update(r) | 183 update(r) |
173 res = [] | 184 res = [] |
174 results.append(res) | 185 results.append(res) |
186 printheader(len(revsets)) | |
175 for idx, rset in enumerate(revsets): | 187 for idx, rset in enumerate(revsets): |
176 data = perf(rset, target=options.repo) | 188 data = perf(rset, target=options.repo) |
177 res.append(data) | 189 res.append(data) |
178 printresult(idx, data, len(revsets)) | 190 printresult(idx, data, len(revsets)) |
179 sys.stdout.flush() | 191 sys.stdout.flush() |
196 print | 208 print |
197 | 209 |
198 for ridx, rset in enumerate(revsets): | 210 for ridx, rset in enumerate(revsets): |
199 | 211 |
200 print "revset #%i: %s" % (ridx, rset) | 212 print "revset #%i: %s" % (ridx, rset) |
213 printheader(len(results)) | |
201 for idx, data in enumerate(results): | 214 for idx, data in enumerate(results): |
202 printresult(idx, data[ridx], len(results)) | 215 printresult(idx, data[ridx], len(results)) |
203 print | 216 print |