Show More
@@ -1,78 +1,85 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | |
|
3 | 3 | # Measure the performance of a list of revsets against multiple revisions |
|
4 | 4 | # defined by parameter. Checkout one by one and run perfrevset with every |
|
5 | 5 | # revset in the list to benchmark its performance. |
|
6 | 6 | # |
|
7 | 7 | # - First argument is a revset of mercurial own repo to runs against. |
|
8 | 8 | # - Second argument is the file from which the revset array will be taken |
|
9 | 9 | # If second argument is omitted read it from standard input |
|
10 | 10 | # |
|
11 | 11 | # You should run this from the root of your mercurial repository. |
|
12 | 12 | # |
|
13 | 13 | # This script also does one run of the current version of mercurial installed |
|
14 | 14 | # to compare performance. |
|
15 | 15 | |
|
16 | 16 | import sys |
|
17 | 17 | from subprocess import check_call, check_output, CalledProcessError |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | def update(rev): |
|
21 | 21 | """update the repo to a revision""" |
|
22 | 22 | try: |
|
23 | 23 | check_call(['hg', 'update', '--quiet', '--check', str(rev)]) |
|
24 | 24 | except CalledProcessError, exc: |
|
25 | 25 | print >> sys.stderr, 'update to revision %s failed, aborting' % rev |
|
26 | 26 | sys.exit(exc.returncode) |
|
27 | 27 | |
|
28 | 28 | def perf(revset): |
|
29 | 29 | """run benchmark for this very revset""" |
|
30 | 30 | try: |
|
31 | 31 | check_call(['./hg', '--config', 'extensions.perf=contrib/perf.py', |
|
32 | 32 | 'perfrevset', revset]) |
|
33 | 33 | except CalledProcessError, exc: |
|
34 | 34 | print >> sys.stderr, 'abort: cannot run revset benchmark' |
|
35 | 35 | sys.exit(exc.returncode) |
|
36 | 36 | |
|
37 | 37 | def printrevision(rev): |
|
38 | 38 | """print data about a revision""" |
|
39 | 39 | sys.stdout.write("Revision: ") |
|
40 | 40 | sys.stdout.flush() |
|
41 | 41 | check_call(['hg', 'log', '--rev', str(rev), '--template', |
|
42 | 42 | '{desc|firstline}\n']) |
|
43 | 43 | |
|
44 | def getrevs(spec): | |
|
45 | """get the list of rev matched by a revset""" | |
|
46 | try: | |
|
47 | out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) | |
|
48 | except CalledProcessError, exc: | |
|
49 | print >> sys.stderr, "abort, can't get revision from %s" % spec | |
|
50 | sys.exit(exc.returncode) | |
|
51 | return [r for r in out.split() if r] | |
|
52 | ||
|
53 | ||
|
44 | 54 | |
|
45 | 55 | target_rev = sys.argv[1] |
|
46 | 56 | |
|
47 | 57 | revsetsfile = sys.stdin |
|
48 | 58 | if len(sys.argv) > 2: |
|
49 | 59 | revsetsfile = open(sys.argv[2]) |
|
50 | 60 | |
|
51 | 61 | revsets = [l.strip() for l in revsetsfile] |
|
52 | 62 | |
|
53 | 63 | print "Revsets to benchmark" |
|
54 | 64 | print "----------------------------" |
|
55 | 65 | |
|
56 | 66 | for idx, rset in enumerate(revsets): |
|
57 | 67 | print "%i) %s" % (idx, rset) |
|
58 | 68 | |
|
59 | 69 | print "----------------------------" |
|
60 | 70 | |
|
61 | 71 | |
|
62 | revs = check_output("hg log --template='{rev}\n' --rev " + target_rev, | |
|
63 | shell=True) | |
|
64 | 72 | |
|
65 | revs = [r for r in revs.split() if r] | |
|
73 | revs = getrevs(target_rev) | |
|
66 | 74 | |
|
67 | # Benchmark revisions | |
|
68 | 75 | for r in revs: |
|
69 | 76 | print "----------------------------" |
|
70 | 77 | printrevision(r) |
|
71 | 78 | print "----------------------------" |
|
72 | 79 | update(r) |
|
73 | 80 | for idx, rset in enumerate(revsets): |
|
74 | 81 | sys.stdout.write("%i) " % idx) |
|
75 | 82 | sys.stdout.flush() |
|
76 | 83 | perf(rset) |
|
77 | 84 | print "----------------------------" |
|
78 | 85 |
General Comments 0
You need to be logged in to leave comments.
Login now