Show More
@@ -1,89 +1,58 b'' | |||||
1 |
#!/usr/bin/env |
|
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 | HG="hg update" |
|
16 | import sys | |
|
17 | from subprocess import check_call, check_output | |||
|
18 | ||||
|
19 | HG="hg update --quiet --check" | |||
17 | PERF="./hg --config extensions.perf=contrib/perf.py perfrevset" |
|
20 | PERF="./hg --config extensions.perf=contrib/perf.py perfrevset" | |
18 | BASE_PERF="hg --config extensions.perf=contrib/perf.py perfrevset" |
|
|||
19 |
|
21 | |||
20 | TARGETS=$1 |
|
22 | target_rev = sys.argv[1] | |
21 | shift |
|
|||
22 | # read from a file or from standard output |
|
|||
23 | if [ $# -ne 0 ]; then |
|
|||
24 | readarray REVSETS < $1 |
|
|||
25 | else |
|
|||
26 | readarray REVSETS |
|
|||
27 | fi |
|
|||
28 |
|
23 | |||
29 | hg update --quiet |
|
24 | revsetsfile = sys.stdin | |
|
25 | if len(sys.argv) > 2: | |||
|
26 | revsetsfile = open(sys.argv[2]) | |||
30 |
|
27 | |||
31 | echo "Starting time benchmarking" |
|
28 | revsets = [l.strip() for l in revsetsfile] | |
32 | echo |
|
|||
33 |
|
29 | |||
34 |
|
|
30 | print "Revsets to benchmark" | |
35 |
|
|
31 | print "----------------------------" | |
36 |
|
32 | |||
37 | for (( j = 0; j < ${#REVSETS[@]}; j++ )); |
|
33 | for idx, rset in enumerate(revsets): | |
38 | do |
|
34 | print "%i) %s" % (idx, rset) | |
39 | echo "${j}) ${REVSETS[$j]}" |
|
|||
40 | done |
|
|||
41 |
|
||||
42 | echo "----------------------------" |
|
|||
43 | echo |
|
|||
44 |
|
35 | |||
45 | # Benchmark baseline |
|
36 | print "----------------------------" | |
46 | echo "Benchmarking baseline" |
|
37 | ||
47 |
|
38 | |||
48 | for (( j = 0; j < ${#REVSETS[@]}; j++ )); |
|
39 | revs = check_output("hg log --template='{rev}\n' --rev " + target_rev, | |
49 | do |
|
40 | shell=True); | |
50 | echo -n "${j}) " |
|
|||
51 | $BASE_PERF "${REVSETS[$j]}" |
|
|||
52 | done |
|
|||
53 |
|
41 | |||
54 | echo |
|
42 | revs = [r for r in revs.split() if r] | |
55 | echo |
|
|||
56 |
|
43 | |||
57 | # Benchmark revisions |
|
44 | # Benchmark revisions | |
58 | for i in $(hg log --template='{rev}\n' --rev $TARGETS); |
|
45 | for r in revs: | |
59 | do |
|
46 | print "----------------------------" | |
60 | echo "----------------------------" |
|
47 | sys.stdout.write("Revision: ") | |
61 | echo -n "Revision: " |
|
48 | sys.stdout.flush() | |
62 |
hg |
|
49 | check_call('hg log -r %s --template "{desc|firstline}\n"' % r, shell=True) | |
63 |
|
||||
64 | echo "----------------------------" |
|
|||
65 | $HG $i |
|
|||
66 | for (( j = 0; j < ${#REVSETS[@]}; j++ )); |
|
|||
67 | do |
|
|||
68 | echo -n "${j}) " |
|
|||
69 | $PERF "${REVSETS[$j]}" |
|
|||
70 | done |
|
|||
71 | echo "----------------------------" |
|
|||
72 | done |
|
|||
73 |
|
50 | |||
74 | $HG |
|
51 | print "----------------------------" | |
75 |
|
52 | check_call(HG + ' ' + r, shell=True) | ||
76 | # Benchmark current code |
|
53 | for idx, rset in enumerate(revsets): | |
77 | echo "Benchmarking current code" |
|
54 | sys.stdout.write("%i) " % idx) | |
|
55 | sys.stdout.flush() | |||
|
56 | check_call(PERF + ' "%s"' % rset, shell=True) | |||
|
57 | print "----------------------------" | |||
78 |
|
58 | |||
79 | for (( j = 0; j < ${#REVSETS[@]}; j++ )); |
|
|||
80 | do |
|
|||
81 | echo -n "${j}) " |
|
|||
82 | $PERF "${REVSETS[$j]}" |
|
|||
83 | done |
|
|||
84 |
|
||||
85 |
|
||||
86 | echo |
|
|||
87 | echo "Time benchmarking finished" |
|
|||
88 |
|
||||
89 |
|
General Comments 0
You need to be logged in to leave comments.
Login now