Show More
@@ -1,147 +1,147 | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | |||
3 | # Measure the performance of a list of revsets against multiple revisions |
|
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 |
|
4 | # defined by parameter. Checkout one by one and run perfrevset with every | |
5 | # revset in the list to benchmark its performance. |
|
5 | # revset in the list to benchmark its performance. | |
6 | # |
|
6 | # | |
7 | # - First argument is a revset of mercurial own repo to runs against. |
|
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 |
|
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 |
|
9 | # If second argument is omitted read it from standard input | |
10 | # |
|
10 | # | |
11 | # You should run this from the root of your mercurial repository. |
|
11 | # You should run this from the root of your mercurial repository. | |
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 | import os |
|
17 | import os | |
18 | from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE |
|
18 | from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE | |
19 | # cannot use argparse, python 2.7 only |
|
19 | # cannot use argparse, python 2.7 only | |
20 | from optparse import OptionParser |
|
20 | from optparse import OptionParser | |
21 |
|
21 | |||
22 | def check_output(*args, **kwargs): |
|
22 | def check_output(*args, **kwargs): | |
23 | kwargs.setdefault('stderr', PIPE) |
|
23 | kwargs.setdefault('stderr', PIPE) | |
24 | kwargs.setdefault('stdout', PIPE) |
|
24 | kwargs.setdefault('stdout', PIPE) | |
25 | proc = Popen(*args, **kwargs) |
|
25 | proc = Popen(*args, **kwargs) | |
26 | output, error = proc.communicate() |
|
26 | output, error = proc.communicate() | |
27 | if proc.returncode != 0: |
|
27 | if proc.returncode != 0: | |
28 | raise CalledProcessError(proc.returncode, ' '.join(args[0])) |
|
28 | raise CalledProcessError(proc.returncode, ' '.join(args[0])) | |
29 | return output |
|
29 | return output | |
30 |
|
30 | |||
31 | def update(rev): |
|
31 | def update(rev): | |
32 | """update the repo to a revision""" |
|
32 | """update the repo to a revision""" | |
33 | try: |
|
33 | try: | |
34 | check_call(['hg', 'update', '--quiet', '--check', str(rev)]) |
|
34 | check_call(['hg', 'update', '--quiet', '--check', str(rev)]) | |
35 | except CalledProcessError, exc: |
|
35 | except CalledProcessError, exc: | |
36 | print >> sys.stderr, 'update to revision %s failed, aborting' % rev |
|
36 | print >> sys.stderr, 'update to revision %s failed, aborting' % rev | |
37 | sys.exit(exc.returncode) |
|
37 | sys.exit(exc.returncode) | |
38 |
|
38 | |||
39 | def perf(revset, target=None): |
|
39 | def perf(revset, target=None): | |
40 | """run benchmark for this very revset""" |
|
40 | """run benchmark for this very revset""" | |
41 | try: |
|
41 | try: | |
42 | cmd = ['./hg', |
|
42 | cmd = ['./hg', | |
43 | '--config', |
|
43 | '--config', | |
44 | 'extensions.perf=' |
|
44 | 'extensions.perf=' | |
45 | + os.path.join(contribdir, 'perf.py'), |
|
45 | + os.path.join(contribdir, 'perf.py'), | |
46 | 'perfrevset', |
|
46 | 'perfrevset', | |
47 | revset] |
|
47 | revset] | |
48 | if target is not None: |
|
48 | if target is not None: | |
49 | cmd.append('-R') |
|
49 | cmd.append('-R') | |
50 | cmd.append(target) |
|
50 | cmd.append(target) | |
51 | output = check_output(cmd, stderr=STDOUT) |
|
51 | output = check_output(cmd, stderr=STDOUT) | |
52 | output = output.lstrip('!') # remove useless ! in this context |
|
52 | output = output.lstrip('!') # remove useless ! in this context | |
53 | return output.strip() |
|
53 | return output.strip() | |
54 | except CalledProcessError, exc: |
|
54 | except CalledProcessError, exc: | |
55 | print >> sys.stderr, 'abort: cannot run revset benchmark' |
|
55 | print >> sys.stderr, 'abort: cannot run revset benchmark' | |
56 | sys.exit(exc.returncode) |
|
56 | sys.exit(exc.returncode) | |
57 |
|
57 | |||
58 | def printrevision(rev): |
|
58 | def printrevision(rev): | |
59 | """print data about a revision""" |
|
59 | """print data about a revision""" | |
60 | sys.stdout.write("Revision: ") |
|
60 | sys.stdout.write("Revision: ") | |
61 | sys.stdout.flush() |
|
61 | sys.stdout.flush() | |
62 | check_call(['hg', 'log', '--rev', str(rev), '--template', |
|
62 | check_call(['hg', 'log', '--rev', str(rev), '--template', | |
63 | '{desc|firstline}\n']) |
|
63 | '{desc|firstline}\n']) | |
64 |
|
64 | |||
65 | def getrevs(spec): |
|
65 | def getrevs(spec): | |
66 | """get the list of rev matched by a revset""" |
|
66 | """get the list of rev matched by a revset""" | |
67 | try: |
|
67 | try: | |
68 | out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) |
|
68 | out = check_output(['hg', 'log', '--template={rev}\n', '--rev', spec]) | |
69 | except CalledProcessError, exc: |
|
69 | except CalledProcessError, exc: | |
70 | print >> sys.stderr, "abort, can't get revision from %s" % spec |
|
70 | print >> sys.stderr, "abort, can't get revision from %s" % spec | |
71 | sys.exit(exc.returncode) |
|
71 | sys.exit(exc.returncode) | |
72 | return [r for r in out.split() if r] |
|
72 | return [r for r in out.split() if r] | |
73 |
|
73 | |||
74 |
|
74 | |||
75 | parser = OptionParser(usage="usage: %prog [options] <revs>") |
|
75 | parser = OptionParser(usage="usage: %prog [options] <revs>") | |
76 | parser.add_option("-f", "--file", |
|
76 | parser.add_option("-f", "--file", | |
77 | help="read revset from FILE (stdin if omited)", |
|
77 | help="read revset from FILE (stdin if omited)", | |
78 | metavar="FILE") |
|
78 | metavar="FILE") | |
79 | parser.add_option("-R", "--repo", |
|
79 | parser.add_option("-R", "--repo", | |
80 | help="run benchmark on REPO", metavar="REPO") |
|
80 | help="run benchmark on REPO", metavar="REPO") | |
81 |
|
81 | |||
82 | (options, args) = parser.parse_args() |
|
82 | (options, args) = parser.parse_args() | |
83 |
|
83 | |||
84 | if len(sys.argv) < 2: |
|
84 | if len(sys.argv) < 2: | |
85 | parser.print_help() |
|
85 | parser.print_help() | |
86 | sys.exit(255) |
|
86 | sys.exit(255) | |
87 |
|
87 | |||
88 | # the directory where both this script and the perf.py extension live. |
|
88 | # the directory where both this script and the perf.py extension live. | |
89 | contribdir = os.path.dirname(__file__) |
|
89 | contribdir = os.path.dirname(__file__) | |
90 |
|
90 | |||
91 | target_rev = args[0] |
|
91 | target_rev = args[0] | |
92 |
|
92 | |||
93 | revsetsfile = sys.stdin |
|
93 | revsetsfile = sys.stdin | |
94 | if options.file: |
|
94 | if options.file: | |
95 | revsetsfile = open(options.file) |
|
95 | revsetsfile = open(options.file) | |
96 |
|
96 | |||
97 | revsets = [l.strip() for l in revsetsfile] |
|
97 | revsets = [l.strip() for l in revsetsfile if not l.startswith('#')] | |
98 |
|
98 | |||
99 | print "Revsets to benchmark" |
|
99 | print "Revsets to benchmark" | |
100 | print "----------------------------" |
|
100 | print "----------------------------" | |
101 |
|
101 | |||
102 | for idx, rset in enumerate(revsets): |
|
102 | for idx, rset in enumerate(revsets): | |
103 | print "%i) %s" % (idx, rset) |
|
103 | print "%i) %s" % (idx, rset) | |
104 |
|
104 | |||
105 | print "----------------------------" |
|
105 | print "----------------------------" | |
106 |
|
106 | |||
107 |
|
107 | |||
108 |
|
108 | |||
109 | revs = getrevs(target_rev) |
|
109 | revs = getrevs(target_rev) | |
110 |
|
110 | |||
111 | results = [] |
|
111 | results = [] | |
112 | for r in revs: |
|
112 | for r in revs: | |
113 | print "----------------------------" |
|
113 | print "----------------------------" | |
114 | printrevision(r) |
|
114 | printrevision(r) | |
115 | print "----------------------------" |
|
115 | print "----------------------------" | |
116 | update(r) |
|
116 | update(r) | |
117 | res = [] |
|
117 | res = [] | |
118 | results.append(res) |
|
118 | results.append(res) | |
119 | for idx, rset in enumerate(revsets): |
|
119 | for idx, rset in enumerate(revsets): | |
120 | data = perf(rset, target=options.repo) |
|
120 | data = perf(rset, target=options.repo) | |
121 | res.append(data) |
|
121 | res.append(data) | |
122 | print "%i)" % idx, data |
|
122 | print "%i)" % idx, data | |
123 | sys.stdout.flush() |
|
123 | sys.stdout.flush() | |
124 | print "----------------------------" |
|
124 | print "----------------------------" | |
125 |
|
125 | |||
126 |
|
126 | |||
127 | print """ |
|
127 | print """ | |
128 |
|
128 | |||
129 | Result by revset |
|
129 | Result by revset | |
130 | ================ |
|
130 | ================ | |
131 | """ |
|
131 | """ | |
132 |
|
132 | |||
133 | print 'Revision:', revs |
|
133 | print 'Revision:', revs | |
134 | for idx, rev in enumerate(revs): |
|
134 | for idx, rev in enumerate(revs): | |
135 | sys.stdout.write('%i) ' % idx) |
|
135 | sys.stdout.write('%i) ' % idx) | |
136 | sys.stdout.flush() |
|
136 | sys.stdout.flush() | |
137 | printrevision(rev) |
|
137 | printrevision(rev) | |
138 |
|
138 | |||
139 |
|
139 | |||
140 |
|
140 | |||
141 |
|
141 | |||
142 | for ridx, rset in enumerate(revsets): |
|
142 | for ridx, rset in enumerate(revsets): | |
143 |
|
143 | |||
144 | print "revset #%i: %s" % (ridx, rset) |
|
144 | print "revset #%i: %s" % (ridx, rset) | |
145 | for idx, data in enumerate(results): |
|
145 | for idx, data in enumerate(results): | |
146 | print '%i) %s' % (idx, data[ridx]) |
|
146 | print '%i) %s' % (idx, data[ridx]) | |
147 |
|
147 |
@@ -1,29 +1,30 | |||||
1 | all() |
|
1 | all() | |
2 | draft() |
|
2 | draft() | |
3 | ::tip |
|
3 | ::tip | |
4 | draft() and ::tip |
|
4 | draft() and ::tip | |
5 | ::tip and draft() |
|
5 | ::tip and draft() | |
6 | 0::tip |
|
6 | 0::tip | |
7 | roots(0::tip) |
|
7 | roots(0::tip) | |
8 | author(lmoscovicz) |
|
8 | author(lmoscovicz) | |
9 | author(mpm) |
|
9 | author(mpm) | |
10 | author(lmoscovicz) or author(mpm) |
|
10 | author(lmoscovicz) or author(mpm) | |
11 | author(mpm) or author(lmoscovicz) |
|
11 | author(mpm) or author(lmoscovicz) | |
12 | tip:0 |
|
12 | tip:0 | |
13 | max(tip:0) |
|
13 | max(tip:0) | |
14 | min(0:tip) |
|
14 | min(0:tip) | |
15 | 0:: |
|
15 | 0:: | |
16 | min(0::) |
|
16 | min(0::) | |
|
17 | # those two `roots(...)` inputs are close to what phase movement use. | |||
17 | roots((tip~100::) - (tip~100::tip)) |
|
18 | roots((tip~100::) - (tip~100::tip)) | |
|
19 | roots((0::) - (0::tip)) | |||
18 | ::p1(p1(tip)):: |
|
20 | ::p1(p1(tip)):: | |
19 | public() |
|
21 | public() | |
20 | :10000 and public() |
|
22 | :10000 and public() | |
21 | draft() |
|
23 | draft() | |
22 | :10000 and draft() |
|
24 | :10000 and draft() | |
23 | max(::(tip~20) - obsolete()) |
|
25 | max(::(tip~20) - obsolete()) | |
24 | roots((0:tip)::) |
|
26 | roots((0:tip)::) | |
25 | (not public() - obsolete()) |
|
27 | (not public() - obsolete()) | |
26 | roots((0::) - (0::tip)) |
|
|||
27 | (_intlist('20000\x0020001')) and merge() |
|
28 | (_intlist('20000\x0020001')) and merge() | |
28 | parents(20000) |
|
29 | parents(20000) | |
29 | (20000::) - (20000) |
|
30 | (20000::) - (20000) |
General Comments 0
You need to be logged in to leave comments.
Login now