annotate contrib/revsetbenchmarks.py @ 20849:5abc2562106a

revsetbenchmark: fix semicolon
author Matt Mackall <mpm@selenic.com>
date Thu, 27 Mar 2014 16:52:24 -0500
parents 11a9393609c8
children d0c2535c7aba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
1 #!/usr/bin/env python
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
2
20746
47fc466825da contrib: have the revset benchmark test script take a revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20745
diff changeset
3 # Measure the performance of a list of revsets against multiple revisions
47fc466825da contrib: have the revset benchmark test script take a revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20745
diff changeset
4 # defined by parameter. Checkout one by one and run perfrevset with every
47fc466825da contrib: have the revset benchmark test script take a revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20745
diff changeset
5 # revset in the list to benchmark its performance.
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
6 #
20747
8c89433ccdcf contrib: make revset benchmark script able to read from stdin
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20746
diff changeset
7 # - First argument is a revset of mercurial own repo to runs against.
8c89433ccdcf contrib: make revset benchmark script able to read from stdin
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20746
diff changeset
8 # - Second argument is the file from which the revset array will be taken
8c89433ccdcf contrib: make revset benchmark script able to read from stdin
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20746
diff changeset
9 # If second argument is omitted read it from standard input
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
10 #
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
11 # You should run this from the root of your mercurial repository.
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
12 #
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
13 # This script also does one run of the current version of mercurial installed
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
14 # to compare performance.
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
15
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
16 import sys
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
17 from subprocess import check_call, check_output
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
18
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
19 HG="hg update --quiet --check"
20830
44e80bf2688f contrib: explicitly enable perf extension for revset tests
Olle Lundberg <geek@nerd.sh>
parents: 20747
diff changeset
20 PERF="./hg --config extensions.perf=contrib/perf.py perfrevset"
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
21
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
22 target_rev = sys.argv[1]
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
23
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
24 revsetsfile = sys.stdin
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
25 if len(sys.argv) > 2:
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
26 revsetsfile = open(sys.argv[2])
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
27
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
28 revsets = [l.strip() for l in revsetsfile]
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
29
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
30 print "Revsets to benchmark"
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
31 print "----------------------------"
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
32
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
33 for idx, rset in enumerate(revsets):
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
34 print "%i) %s" % (idx, rset)
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
35
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
36 print "----------------------------"
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
37 print
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
38
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
39 revs = check_output("hg log --template='{rev}\n' --rev " + target_rev,
20849
5abc2562106a revsetbenchmark: fix semicolon
Matt Mackall <mpm@selenic.com>
parents: 20848
diff changeset
40 shell=True)
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
41
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
42 revs = [r for r in revs.split() if r]
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
43
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
44 # Benchmark revisions
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
45 for r in revs:
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
46 print "----------------------------"
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
47 sys.stdout.write("Revision: ")
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
48 sys.stdout.flush()
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
49 check_call('hg log -r %s --template "{desc|firstline}\n"' % r, shell=True)
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
50
20848
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
51 print "----------------------------"
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
52 check_call(HG + ' ' + r, shell=True)
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
53 for idx, rset in enumerate(revsets):
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
54 sys.stdout.write("%i) " % idx)
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
55 sys.stdout.flush()
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
56 check_call(PERF + ' "%s"' % rset, shell=True)
11a9393609c8 revsetbenchmark: simplify and convert the script to python
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20847
diff changeset
57 print "----------------------------"
20745
5fb7c36d751f contrib: added revset performance benchmarking script
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
diff changeset
58