comparison contrib/revsetbenchmarks.py @ 20848:11a9393609c8

revsetbenchmark: simplify and convert the script to python The script is now in python. That translation is very raw, more improvement to comes: The "current code" and "base" entry have been dropped. This is trivial to get same result using a tagged revision or "." in the list of benchmarked revision.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 26 Mar 2014 18:03:30 -0700
parents contrib/revsetbenchmarks.sh@c3f455337c6a
children 5abc2562106a
comparison
equal deleted inserted replaced
20847:c3f455337c6a 20848:11a9393609c8
1 #!/usr/bin/env python
2
3 # Measure the performance of a list of revsets against multiple revisions
4 # defined by parameter. Checkout one by one and run perfrevset with every
5 # revset in the list to benchmark its performance.
6 #
7 # - First argument is a revset of mercurial own repo to runs against.
8 # - Second argument is the file from which the revset array will be taken
9 # If second argument is omitted read it from standard input
10 #
11 # You should run this from the root of your mercurial repository.
12 #
13 # This script also does one run of the current version of mercurial installed
14 # to compare performance.
15
16 import sys
17 from subprocess import check_call, check_output
18
19 HG="hg update --quiet --check"
20 PERF="./hg --config extensions.perf=contrib/perf.py perfrevset"
21
22 target_rev = sys.argv[1]
23
24 revsetsfile = sys.stdin
25 if len(sys.argv) > 2:
26 revsetsfile = open(sys.argv[2])
27
28 revsets = [l.strip() for l in revsetsfile]
29
30 print "Revsets to benchmark"
31 print "----------------------------"
32
33 for idx, rset in enumerate(revsets):
34 print "%i) %s" % (idx, rset)
35
36 print "----------------------------"
37 print
38
39 revs = check_output("hg log --template='{rev}\n' --rev " + target_rev,
40 shell=True);
41
42 revs = [r for r in revs.split() if r]
43
44 # Benchmark revisions
45 for r in revs:
46 print "----------------------------"
47 sys.stdout.write("Revision: ")
48 sys.stdout.flush()
49 check_call('hg log -r %s --template "{desc|firstline}\n"' % r, shell=True)
50
51 print "----------------------------"
52 check_call(HG + ' ' + r, shell=True)
53 for idx, rset in enumerate(revsets):
54 sys.stdout.write("%i) " % idx)
55 sys.stdout.flush()
56 check_call(PERF + ' "%s"' % rset, shell=True)
57 print "----------------------------"
58