Show More
@@ -1,89 +1,58 b'' | |||
|
1 |
#!/usr/bin/env |
|
|
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 | HG="hg update" | |
|
16 | import sys | |
|
17 | from subprocess import check_call, check_output | |
|
18 | ||
|
19 | HG="hg update --quiet --check" | |
|
17 | 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 | |
|
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 | |
|
22 | target_rev = sys.argv[1] | |
|
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" | |
|
32 | echo | |
|
28 | revsets = [l.strip() for l in revsetsfile] | |
|
33 | 29 | |
|
34 |
|
|
|
35 |
|
|
|
30 | print "Revsets to benchmark" | |
|
31 | print "----------------------------" | |
|
36 | 32 | |
|
37 | for (( j = 0; j < ${#REVSETS[@]}; j++ )); | |
|
38 | do | |
|
39 | echo "${j}) ${REVSETS[$j]}" | |
|
40 | done | |
|
41 | ||
|
42 | echo "----------------------------" | |
|
43 | echo | |
|
33 | for idx, rset in enumerate(revsets): | |
|
34 | print "%i) %s" % (idx, rset) | |
|
44 | 35 | |
|
45 | # Benchmark baseline | |
|
46 | echo "Benchmarking baseline" | |
|
36 | print "----------------------------" | |
|
37 | ||
|
47 | 38 | |
|
48 | for (( j = 0; j < ${#REVSETS[@]}; j++ )); | |
|
49 | do | |
|
50 | echo -n "${j}) " | |
|
51 | $BASE_PERF "${REVSETS[$j]}" | |
|
52 | done | |
|
39 | revs = check_output("hg log --template='{rev}\n' --rev " + target_rev, | |
|
40 | shell=True); | |
|
53 | 41 | |
|
54 | echo | |
|
55 | echo | |
|
42 | revs = [r for r in revs.split() if r] | |
|
56 | 43 | |
|
57 | 44 | # Benchmark revisions |
|
58 | for i in $(hg log --template='{rev}\n' --rev $TARGETS); | |
|
59 | do | |
|
60 | echo "----------------------------" | |
|
61 | echo -n "Revision: " | |
|
62 |
hg |
|
|
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 | |
|
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) | |
|
73 | 50 | |
|
74 | $HG | |
|
75 | ||
|
76 | # Benchmark current code | |
|
77 | echo "Benchmarking current code" | |
|
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 "----------------------------" | |
|
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