Mercurial > public > mercurial-scm > hg
comparison contrib/revsetbenchmarks.py @ 20854:bad5399c5d5f
revsetbenchmark: retrieve the benchmark value in python
We retrieve the output of the perf extension and print it ourself. This open the
door to processing of this data in the script.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 26 Mar 2014 18:39:56 -0700 |
parents | 95293cf67871 |
children | dfad9bb23ab4 |
comparison
equal
deleted
inserted
replaced
20853:95293cf67871 | 20854:bad5399c5d5f |
---|---|
12 # | 12 # |
13 # This script also does one run of the current version of mercurial installed | 13 # This script also does one run of the current version of mercurial installed |
14 # to compare performance. | 14 # to compare performance. |
15 | 15 |
16 import sys | 16 import sys |
17 from subprocess import check_call, check_output, CalledProcessError | 17 from subprocess import check_call, check_output, CalledProcessError, STDOUT |
18 | 18 |
19 | 19 |
20 def update(rev): | 20 def update(rev): |
21 """update the repo to a revision""" | 21 """update the repo to a revision""" |
22 try: | 22 try: |
26 sys.exit(exc.returncode) | 26 sys.exit(exc.returncode) |
27 | 27 |
28 def perf(revset): | 28 def perf(revset): |
29 """run benchmark for this very revset""" | 29 """run benchmark for this very revset""" |
30 try: | 30 try: |
31 check_call(['./hg', '--config', 'extensions.perf=contrib/perf.py', | 31 output = check_output(['./hg', |
32 'perfrevset', revset]) | 32 '--config', |
33 'extensions.perf=contrib/perf.py', | |
34 'perfrevset', | |
35 revset], | |
36 stderr=STDOUT) | |
37 output = output.lstrip('!') # remove useless ! in this context | |
38 return output.strip() | |
33 except CalledProcessError, exc: | 39 except CalledProcessError, exc: |
34 print >> sys.stderr, 'abort: cannot run revset benchmark' | 40 print >> sys.stderr, 'abort: cannot run revset benchmark' |
35 sys.exit(exc.returncode) | 41 sys.exit(exc.returncode) |
36 | 42 |
37 def printrevision(rev): | 43 def printrevision(rev): |
76 print "----------------------------" | 82 print "----------------------------" |
77 printrevision(r) | 83 printrevision(r) |
78 print "----------------------------" | 84 print "----------------------------" |
79 update(r) | 85 update(r) |
80 for idx, rset in enumerate(revsets): | 86 for idx, rset in enumerate(revsets): |
81 sys.stdout.write("%i) " % idx) | 87 |
82 sys.stdout.flush() | 88 print "%i)" % idx, perf(rset) |
83 perf(rset) | |
84 print "----------------------------" | 89 print "----------------------------" |
85 | 90 |