Show More
@@ -8,13 +8,22 b'' | |||
|
8 | 8 | # |
|
9 | 9 | # call with --help for details |
|
10 | 10 | |
|
11 | import sys | |
|
11 | from __future__ import absolute_import, print_function | |
|
12 | import math | |
|
12 | 13 | import os |
|
13 | 14 | import re |
|
14 |
import |
|
|
15 | from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE | |
|
15 | import sys | |
|
16 | from subprocess import ( | |
|
17 | CalledProcessError, | |
|
18 | check_call, | |
|
19 | PIPE, | |
|
20 | Popen, | |
|
21 | STDOUT, | |
|
22 | ) | |
|
16 | 23 | # cannot use argparse, python 2.7 only |
|
17 |
from optparse import |
|
|
24 | from optparse import ( | |
|
25 | OptionParser, | |
|
26 | ) | |
|
18 | 27 | |
|
19 | 28 | DEFAULTVARIANTS = ['plain', 'min', 'max', 'first', 'last', |
|
20 | 29 | 'reverse', 'reverse+first', 'reverse+last', |
@@ -36,7 +45,7 b' def update(rev):' | |||
|
36 | 45 | check_output(['make', 'local'], |
|
37 | 46 | stderr=None) # suppress output except for error/warning |
|
38 | 47 | except CalledProcessError as exc: |
|
39 |
print |
|
|
48 | print('update to revision %s failed, aborting'%rev, file=sys.stderr) | |
|
40 | 49 | sys.exit(exc.returncode) |
|
41 | 50 | |
|
42 | 51 | |
@@ -62,11 +71,11 b' def perf(revset, target=None, contexts=F' | |||
|
62 | 71 | output = hg(args, repo=target) |
|
63 | 72 | return parseoutput(output) |
|
64 | 73 | except CalledProcessError as exc: |
|
65 |
print |
|
|
74 | print('abort: cannot run revset benchmark: %s'%exc.cmd, file=sys.stderr) | |
|
66 | 75 | if getattr(exc, 'output', None) is None: # no output before 2.7 |
|
67 |
print |
|
|
76 | print('(no output)', file=sys.stderr) | |
|
68 | 77 | else: |
|
69 |
print |
|
|
78 | print(exc.output, file=sys.stderr) | |
|
70 | 79 | return None |
|
71 | 80 | |
|
72 | 81 | outputre = re.compile(r'! wall (\d+.\d+) comb (\d+.\d+) user (\d+.\d+) ' |
@@ -80,8 +89,8 b' def parseoutput(output):' | |||
|
80 | 89 | """ |
|
81 | 90 | match = outputre.search(output) |
|
82 | 91 | if not match: |
|
83 |
print |
|
|
84 |
print |
|
|
92 | print('abort: invalid output:', file=sys.stderr) | |
|
93 | print(output, file=sys.stderr) | |
|
85 | 94 | sys.exit(1) |
|
86 | 95 | return {'comb': float(match.group(2)), |
|
87 | 96 | 'count': int(match.group(5)), |
@@ -183,7 +192,7 b' def printresult(variants, idx, data, max' | |||
|
183 | 192 | out.append(formattiming(data[var]['user'])) |
|
184 | 193 | out.append(formattiming(data[var]['sys'])) |
|
185 | 194 | out.append('%6d' % data[var]['count']) |
|
186 |
print |
|
|
195 | print(mask % (idx, ' '.join(out))) | |
|
187 | 196 | |
|
188 | 197 | def printheader(variants, maxidx, verbose=False, relative=False): |
|
189 | 198 | header = [' ' * (idxwidth(maxidx) + 1)] |
@@ -200,14 +209,14 b' def printheader(variants, maxidx, verbos' | |||
|
200 | 209 | header.append('%-8s' % 'user') |
|
201 | 210 | header.append('%-8s' % 'sys') |
|
202 | 211 | header.append('%6s' % 'count') |
|
203 |
print |
|
|
212 | print(' '.join(header)) | |
|
204 | 213 | |
|
205 | 214 | def getrevs(spec): |
|
206 | 215 | """get the list of rev matched by a revset""" |
|
207 | 216 | try: |
|
208 | 217 | out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) |
|
209 | 218 | except CalledProcessError as exc: |
|
210 |
print |
|
|
219 | print("abort, can't get revision from %s"%spec, file=sys.stderr) | |
|
211 | 220 | sys.exit(exc.returncode) |
|
212 | 221 | return [r for r in out.split() if r] |
|
213 | 222 | |
@@ -261,14 +270,14 b' if options.file:' | |||
|
261 | 270 | revsets = [l.strip() for l in revsetsfile if not l.startswith('#')] |
|
262 | 271 | revsets = [l for l in revsets if l] |
|
263 | 272 | |
|
264 |
print |
|
|
265 |
print |
|
|
273 | print("Revsets to benchmark") | |
|
274 | print("----------------------------") | |
|
266 | 275 | |
|
267 | 276 | for idx, rset in enumerate(revsets): |
|
268 |
print |
|
|
277 | print("%i) %s" % (idx, rset)) | |
|
269 | 278 | |
|
270 |
print |
|
|
271 | ||
|
279 | print("----------------------------") | |
|
280 | print() | |
|
272 | 281 | |
|
273 | 282 | revs = [] |
|
274 | 283 | for a in args: |
@@ -278,9 +287,9 b" variants = options.variants.split(',')" | |||
|
278 | 287 | |
|
279 | 288 | results = [] |
|
280 | 289 | for r in revs: |
|
281 |
print |
|
|
290 | print("----------------------------") | |
|
282 | 291 | printrevision(r) |
|
283 |
print |
|
|
292 | print("----------------------------") | |
|
284 | 293 | update(r) |
|
285 | 294 | res = [] |
|
286 | 295 | results.append(res) |
@@ -295,31 +304,31 b' for r in revs:' | |||
|
295 | 304 | printresult(variants, idx, varres, len(revsets), |
|
296 | 305 | verbose=options.verbose) |
|
297 | 306 | sys.stdout.flush() |
|
298 |
print |
|
|
307 | print("----------------------------") | |
|
299 | 308 | |
|
300 | 309 | |
|
301 |
print |
|
|
310 | print(""" | |
|
302 | 311 | |
|
303 | 312 | Result by revset |
|
304 | 313 | ================ |
|
305 | """ | |
|
314 | """) | |
|
306 | 315 | |
|
307 |
print |
|
|
316 | print('Revision:') | |
|
308 | 317 | for idx, rev in enumerate(revs): |
|
309 | 318 | sys.stdout.write('%i) ' % idx) |
|
310 | 319 | sys.stdout.flush() |
|
311 | 320 | printrevision(rev) |
|
312 | 321 | |
|
313 | ||
|
314 | ||
|
322 | print() | |
|
323 | print() | |
|
315 | 324 | |
|
316 | 325 | for ridx, rset in enumerate(revsets): |
|
317 | 326 | |
|
318 |
print |
|
|
327 | print("revset #%i: %s" % (ridx, rset)) | |
|
319 | 328 | printheader(variants, len(results), verbose=options.verbose, relative=True) |
|
320 | 329 | ref = None |
|
321 | 330 | for idx, data in enumerate(results): |
|
322 | 331 | printresult(variants, idx, data[ridx], len(results), |
|
323 | 332 | verbose=options.verbose, reference=ref) |
|
324 | 333 | ref = data[ridx] |
|
325 | ||
|
334 | print() |
@@ -5,8 +5,6 b'' | |||
|
5 | 5 | $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py |
|
6 | 6 | contrib/import-checker.py not using absolute_import |
|
7 | 7 | contrib/import-checker.py requires print_function |
|
8 | contrib/revsetbenchmarks.py not using absolute_import | |
|
9 | contrib/revsetbenchmarks.py requires print_function | |
|
10 | 8 | doc/check-seclevel.py not using absolute_import |
|
11 | 9 | doc/gendoc.py not using absolute_import |
|
12 | 10 | doc/hgmanpage.py not using absolute_import |
General Comments 0
You need to be logged in to leave comments.
Login now