##// END OF EJS Templates
revsetbenchmark: simplify and convert the script to python...
Pierre-Yves David -
r20848:11a93936 default
parent child Browse files
Show More
@@ -1,4 +1,4 b''
1 #!/usr/bin/env bash
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
@@ -13,77 +13,46 b''
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 echo "Revsets to benchmark"
30 print "Revsets to benchmark"
35 echo "----------------------------"
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 print
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 log -r $i --template "{desc|firstline}\n"
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