# HG changeset patch # User Pierre-Yves David # Date 1395884396 25200 # Node ID bad5399c5d5f333777e4805878fd235ea74d955d # Parent 95293cf67871aa7689acaa9d03250071184eff27 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. diff -r 95293cf67871 -r bad5399c5d5f contrib/revsetbenchmarks.py --- a/contrib/revsetbenchmarks.py Wed Mar 26 18:36:19 2014 -0700 +++ b/contrib/revsetbenchmarks.py Wed Mar 26 18:39:56 2014 -0700 @@ -14,7 +14,7 @@ # to compare performance. import sys -from subprocess import check_call, check_output, CalledProcessError +from subprocess import check_call, check_output, CalledProcessError, STDOUT def update(rev): @@ -28,8 +28,14 @@ def perf(revset): """run benchmark for this very revset""" try: - check_call(['./hg', '--config', 'extensions.perf=contrib/perf.py', - 'perfrevset', revset]) + output = check_output(['./hg', + '--config', + 'extensions.perf=contrib/perf.py', + 'perfrevset', + revset], + stderr=STDOUT) + output = output.lstrip('!') # remove useless ! in this context + return output.strip() except CalledProcessError, exc: print >> sys.stderr, 'abort: cannot run revset benchmark' sys.exit(exc.returncode) @@ -78,8 +84,7 @@ print "----------------------------" update(r) for idx, rset in enumerate(revsets): - sys.stdout.write("%i) " % idx) - sys.stdout.flush() - perf(rset) + + print "%i)" % idx, perf(rset) print "----------------------------"