Mercurial > hg
annotate contrib/perf.py @ 16770:b3435385f99f
clone: add progress calls to uncompressed code path
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 21 May 2012 14:25:46 -0500 |
parents | f366d4c2ff34 |
children | 1dc08dc63c09 |
rev | line source |
---|---|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # perf.py - performance test routines |
8873
e872ef2e6758
help: add/fix docstrings for a bunch of extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8656
diff
changeset
|
2 '''helper extension to measure performance''' |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
4 from mercurial import cmdutil, scmutil, util, match, commands |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 import time, os, sys |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
6 |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
7 def timer(func, title=None): |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 results = [] |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
9 begin = time.time() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
10 count = 0 |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14322
diff
changeset
|
11 while True: |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
12 ostart = os.times() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
13 cstart = time.time() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
14 r = func() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
15 cstop = time.time() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
16 ostop = os.times() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
17 count += 1 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 a, b = ostart, ostop |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
19 results.append((cstop - cstart, b[0] - a[0], b[1]-a[1])) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
20 if cstop - begin > 3 and count >= 100: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
21 break |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
22 if cstop - begin > 10 and count >= 3: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
23 break |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
24 if title: |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
25 sys.stderr.write("! %s\n" % title) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
26 if r: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
27 sys.stderr.write("! result: %s\n" % r) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
28 m = min(results) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
29 sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n" |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
30 % (m[0], m[1] + m[2], m[1], m[2], count)) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
31 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
32 def perfwalk(ui, repo, *pats): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 try: |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14494
diff
changeset
|
34 m = scmutil.match(repo[None], pats, {}) |
10176
24ce8f0c0a39
dirstate: don't check state of subrepo directories
Augie Fackler <durin42@gmail.com>
parents:
9932
diff
changeset
|
35 timer(lambda: len(list(repo.dirstate.walk(m, [], True, False)))) |
16689
f366d4c2ff34
cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
36 except Exception: |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 try: |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14494
diff
changeset
|
38 m = scmutil.match(repo[None], pats, {}) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10176
diff
changeset
|
39 timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)])) |
16689
f366d4c2ff34
cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
40 except Exception: |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
41 timer(lambda: len(list(cmdutil.walk(repo, pats, {})))) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
42 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
43 def perfstatus(ui, repo, *pats): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
44 #m = match.always(repo.root, repo.getcwd()) |
16683 | 45 #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, |
46 # False)))) | |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
47 timer(lambda: sum(map(len, repo.status()))) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
48 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 def perfheads(ui, repo): |
16260
33fcad3cfbbc
perf: tweak tests for testing index performance improvements
Matt Mackall <mpm@selenic.com>
parents:
14671
diff
changeset
|
50 timer(lambda: len(repo.changelog.headrevs())) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
51 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
52 def perftags(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
53 import mercurial.changelog, mercurial.manifest |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
54 def t(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
55 repo.changelog = mercurial.changelog.changelog(repo.sopener) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
56 repo.manifest = mercurial.manifest.manifest(repo.sopener) |
9146
5614a628d173
localrepo: rename in-memory tag cache instance attributes (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
8873
diff
changeset
|
57 repo._tags = None |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
58 return len(repo.tags()) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
59 timer(t) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
60 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
61 def perfdirstate(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
62 "a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
63 def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
64 repo.dirstate.invalidate() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
65 "a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
66 timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
67 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
68 def perfdirstatedirs(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
69 "a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
70 def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
71 "a" in repo.dirstate._dirs |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
72 del repo.dirstate._dirs |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
73 timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
74 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
75 def perfmanifest(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
76 def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
77 t = repo.manifest.tip() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
78 m = repo.manifest.read(t) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
79 repo.manifest.mapcache = None |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
80 repo.manifest._cache = None |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
81 timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
82 |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
83 def perfchangeset(ui, repo, rev): |
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
84 n = repo[rev].node() |
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
85 def d(): |
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
86 c = repo.changelog.read(n) |
16266
77d56a5e74a5
perf: add a changeset test
Matt Mackall <mpm@selenic.com>
parents:
16262
diff
changeset
|
87 #repo.changelog._cache = None |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
88 timer(d) |
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
89 |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
90 def perfindex(ui, repo): |
13255
2696730ca233
perf: make perfindex results useful on hg with lazyparser
Matt Mackall <mpm@selenic.com>
parents:
13254
diff
changeset
|
91 import mercurial.revlog |
13277
9f707b297b0f
perf: restore lazyindex hack
Matt Mackall <mpm@selenic.com>
parents:
13262
diff
changeset
|
92 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
13254
5ef5eb1f3515
revlog: only build the nodemap on demand
Matt Mackall <mpm@selenic.com>
parents:
13253
diff
changeset
|
93 n = repo["tip"].node() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
94 def d(): |
16260
33fcad3cfbbc
perf: tweak tests for testing index performance improvements
Matt Mackall <mpm@selenic.com>
parents:
14671
diff
changeset
|
95 cl = mercurial.revlog.revlog(repo.sopener, "00changelog.i") |
33fcad3cfbbc
perf: tweak tests for testing index performance improvements
Matt Mackall <mpm@selenic.com>
parents:
14671
diff
changeset
|
96 cl.rev(n) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
97 timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
98 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
99 def perfstartup(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 cmd = sys.argv[0] |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
101 def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
102 os.system("HGRCPATH= %s version -q > /dev/null" % cmd) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
103 timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
105 def perfparents(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
106 nl = [repo.changelog.node(i) for i in xrange(1000)] |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
108 for n in nl: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
109 repo.changelog.parents(n) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
110 timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
112 def perflookup(ui, repo, rev): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
113 timer(lambda: len(repo.lookup(rev))) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
114 |
16309 | 115 def perfnodelookup(ui, repo, rev): |
116 import mercurial.revlog | |
117 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg | |
118 n = repo[rev].node() | |
119 def d(): | |
120 cl = mercurial.revlog.revlog(repo.sopener, "00changelog.i") | |
121 cl.rev(n) | |
122 timer(d) | |
123 | |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
124 def perfnodelookup(ui, repo, rev): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
125 import mercurial.revlog |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
126 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
127 n = repo[rev].node() |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
128 cl = mercurial.revlog.revlog(repo.sopener, "00changelog.i") |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
129 # behave somewhat consistently across internal API changes |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
130 if util.safehasattr(cl, 'clearcaches'): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
131 clearcaches = cl.clearcaches |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
132 elif util.safehasattr(cl, '_nodecache'): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
133 from mercurial.node import nullid, nullrev |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
134 def clearcaches(): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
135 cl._nodecache = {nullid: nullrev} |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
136 cl._nodepos = None |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
137 else: |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
138 def clearcaches(): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
139 pass |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
140 def d(): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
141 cl.rev(n) |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
142 clearcaches() |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
143 timer(d) |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
144 |
9932
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
145 def perflog(ui, repo, **opts): |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
146 ui.pushbuffer() |
9932
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
147 timer(lambda: commands.log(ui, repo, rev=[], date='', user='', |
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
148 copies=opts.get('rename'))) |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
149 ui.popbuffer() |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
150 |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
151 def perftemplating(ui, repo): |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
152 ui.pushbuffer() |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
153 timer(lambda: commands.log(ui, repo, rev=[], date='', user='', |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
154 template='{date|shortdate} [{rev}:{node|short}]' |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
155 ' {author|person}: {desc|firstline}\n')) |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
156 ui.popbuffer() |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
157 |
16386
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
158 def perfcca(ui, repo): |
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
159 timer(lambda: scmutil.casecollisionauditor(ui, False, repo[None])) |
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
160 |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
161 def perffncacheload(ui, repo): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
162 from mercurial import scmutil, store |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
163 s = store.store(set(['store','fncache']), repo.path, scmutil.opener) |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
164 def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
165 s.fncache._load() |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
166 timer(d) |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
167 |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
168 def perffncachewrite(ui, repo): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
169 from mercurial import scmutil, store |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
170 s = store.store(set(['store','fncache']), repo.path, scmutil.opener) |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
171 s.fncache._load() |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
172 def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
173 s.fncache._dirty = True |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
174 s.fncache.write() |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
175 timer(d) |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
176 |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
177 def perfdiffwd(ui, repo): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
178 """Profile diff of working directory changes""" |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
179 options = { |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
180 'w': 'ignore_all_space', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
181 'b': 'ignore_space_change', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
182 'B': 'ignore_blank_lines', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
183 } |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
184 |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
185 for diffopt in ('', 'w', 'b', 'B', 'wB'): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
186 opts = dict((options[c], '1') for c in diffopt) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
187 def d(): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
188 ui.pushbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
189 commands.diff(ui, repo, **opts) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
190 ui.popbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
191 title = 'diffopts: %s' % (diffopt and ('-' + diffopt) or 'none') |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
192 timer(d, title) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
193 |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
194 def perfrevlog(ui, repo, file_, **opts): |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
195 from mercurial import revlog |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
196 dist = opts['dist'] |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
197 def d(): |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
198 r = revlog.revlog(lambda fn: open(fn, 'rb'), file_) |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
199 for x in xrange(0, len(r), dist): |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
200 r.revision(r.node(x)) |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
201 |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
202 timer(d) |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
203 |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
204 cmdtable = { |
16386
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
205 'perfcca': (perfcca, []), |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
206 'perffncacheload': (perffncacheload, []), |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
207 'perffncachewrite': (perffncachewrite, []), |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
208 'perflookup': (perflookup, []), |
16309 | 209 'perfnodelookup': (perfnodelookup, []), |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
210 'perfparents': (perfparents, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
211 'perfstartup': (perfstartup, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
212 'perfstatus': (perfstatus, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
213 'perfwalk': (perfwalk, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
214 'perfmanifest': (perfmanifest, []), |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
215 'perfchangeset': (perfchangeset, []), |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
216 'perfindex': (perfindex, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
217 'perfheads': (perfheads, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
218 'perftags': (perftags, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
219 'perfdirstate': (perfdirstate, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
220 'perfdirstatedirs': (perfdirstate, []), |
9932
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
221 'perflog': (perflog, |
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
222 [('', 'rename', False, 'ask log to follow renames')]), |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
223 'perftemplating': (perftemplating, []), |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
224 'perfdiffwd': (perfdiffwd, []), |
11713
57a8894e3f75
perf: break down long line
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11694
diff
changeset
|
225 'perfrevlog': (perfrevlog, |
57a8894e3f75
perf: break down long line
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11694
diff
changeset
|
226 [('d', 'dist', 100, 'distance between the revisions')], |
57a8894e3f75
perf: break down long line
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11694
diff
changeset
|
227 "[INDEXFILE]"), |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
228 } |