annotate contrib/perf.py @ 18871:a2d4ab4f575d

perf: add a command to test addremove performance Upcoming patches will improve addremove performance. This command will be used to demonstrate that improvement.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 01 Apr 2013 23:09:36 -0700
parents c1f416e4bc80
children 2e9fe9e2671f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
18240
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
4 from mercurial import cmdutil, scmutil, util, match, commands, obsolete
18817
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
5 from mercurial import repoview, branchmap, merge
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
6 import time, os, sys
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
8 cmdtable = {}
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
9 command = cmdutil.command(cmdtable)
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
10
9826
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
11 def timer(func, title=None):
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
12 results = []
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
13 begin = time.time()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
14 count = 0
14494
1ffeeb91c55d check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents: 14322
diff changeset
15 while True:
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
16 ostart = os.times()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
17 cstart = time.time()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
18 r = func()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
19 cstop = time.time()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
20 ostop = os.times()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
21 count += 1
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
22 a, b = ostart, ostop
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
23 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
24 if cstop - begin > 3 and count >= 100:
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
25 break
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
26 if cstop - begin > 10 and count >= 3:
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
27 break
9826
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
28 if title:
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
29 sys.stderr.write("! %s\n" % title)
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
30 if r:
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
31 sys.stderr.write("! result: %s\n" % r)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
32 m = min(results)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
33 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
34 % (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
35
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
36 @command('perfwalk')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
37 def perfwalk(ui, repo, *pats):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
38 try:
14671
35c2cc322ba8 scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents: 14494
diff changeset
39 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
40 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
41 except Exception:
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
42 try:
14671
35c2cc322ba8 scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents: 14494
diff changeset
43 m = scmutil.match(repo[None], pats, {})
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10176
diff changeset
44 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
45 except Exception:
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
46 timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
47
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
48 @command('perfstatus',
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
49 [('u', 'unknown', False,
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
50 'ask status to look for unknown files')])
18033
00ac420f24ee perf: add option to perfstatus to get the status of unknown files
Siddharth Agarwal <sid0@fb.com>
parents: 17780
diff changeset
51 def perfstatus(ui, repo, **opts):
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
52 #m = match.always(repo.root, repo.getcwd())
16683
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16414
diff changeset
53 #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False,
525fdb738975 cleanup: eradicate long lines
Brodie Rao <brodie@sf.io>
parents: 16414
diff changeset
54 # False))))
18033
00ac420f24ee perf: add option to perfstatus to get the status of unknown files
Siddharth Agarwal <sid0@fb.com>
parents: 17780
diff changeset
55 timer(lambda: sum(map(len, repo.status(**opts))))
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
56
18871
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
57 @command('perfaddremove')
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
58 def perfaddremove(ui, repo):
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
59 try:
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
60 oldquiet = repo.ui.quiet
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
61 repo.ui.quiet = True
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
62 timer(lambda: scmutil.addremove(repo, dry_run=True))
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
63 finally:
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
64 repo.ui.quiet = oldquiet
a2d4ab4f575d perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents: 18845
diff changeset
65
16785
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
66 def clearcaches(cl):
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
67 # behave somewhat consistently across internal API changes
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
68 if util.safehasattr(cl, 'clearcaches'):
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
69 cl.clearcaches()
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
70 elif util.safehasattr(cl, '_nodecache'):
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
71 from mercurial.node import nullid, nullrev
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
72 cl._nodecache = {nullid: nullrev}
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
73 cl._nodepos = None
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
74
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
75 @command('perfheads')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
76 def perfheads(ui, repo):
16785
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
77 cl = repo.changelog
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
78 def d():
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
79 len(cl.headrevs())
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
80 clearcaches(cl)
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
81 timer(d)
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
82
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
83 @command('perftags')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
84 def perftags(ui, repo):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
85 import mercurial.changelog, mercurial.manifest
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
86 def t():
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
87 repo.changelog = mercurial.changelog.changelog(repo.sopener)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
88 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
89 repo._tags = None
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
90 return len(repo.tags())
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
91 timer(t)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
92
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
93 @command('perfancestors')
16802
7e5d94381cd1 perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16788
diff changeset
94 def perfancestors(ui, repo):
7e5d94381cd1 perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16788
diff changeset
95 heads = repo.changelog.headrevs()
7e5d94381cd1 perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16788
diff changeset
96 def d():
16866
91f3ac205816 revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents: 16858
diff changeset
97 for a in repo.changelog.ancestors(heads):
16802
7e5d94381cd1 perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16788
diff changeset
98 pass
7e5d94381cd1 perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16788
diff changeset
99 timer(d)
7e5d94381cd1 perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16788
diff changeset
100
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
101 @command('perfancestorset')
18080
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
102 def perfancestorset(ui, repo, revset):
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
103 revs = repo.revs(revset)
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
104 heads = repo.changelog.headrevs()
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
105 def d():
18091
f7f8159caad3 ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents: 18080
diff changeset
106 s = repo.changelog.ancestors(heads)
18080
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
107 for rev in revs:
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
108 rev in s
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
109 timer(d)
486bfb200b3f perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents: 18062
diff changeset
110
18845
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
111 @command('perfdirs')
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
112 def perfdirs(ui, repo):
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
113 dirstate = repo.dirstate
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
114 'a' in dirstate
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
115 def d():
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
116 dirstate.dirs()
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
117 del dirstate._dirs
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
118 timer(d)
c1f416e4bc80 perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents: 18837
diff changeset
119
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
120 @command('perfdirstate')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
121 def perfdirstate(ui, repo):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
122 "a" in repo.dirstate
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
123 def d():
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
124 repo.dirstate.invalidate()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
125 "a" in repo.dirstate
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
126 timer(d)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
127
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
128 @command('perfdirstatedirs')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
129 def perfdirstatedirs(ui, repo):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
130 "a" in repo.dirstate
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
131 def d():
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
132 "a" in repo.dirstate._dirs
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
133 del repo.dirstate._dirs
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
134 timer(d)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
135
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
136 @command('perfdirstatewrite')
16788
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
137 def perfdirstatewrite(ui, repo):
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
138 ds = repo.dirstate
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
139 "a" in ds
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
140 def d():
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
141 ds._dirty = True
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
142 ds.write()
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
143 timer(d)
7e72c1609862 perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents: 16785
diff changeset
144
18817
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
145 @command('perfmergecalculate',
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
146 [('r', 'rev', '.', 'rev to merge against')])
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
147 def perfmergecalculate(ui, repo, rev):
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
148 wctx = repo[None]
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
149 rctx = scmutil.revsingle(repo, rev, rev)
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
150 ancestor = wctx.ancestor(rctx)
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
151 # we don't want working dir files to be stat'd in the benchmark, so prime
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
152 # that cache
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
153 wctx.dirty()
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
154 def d():
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
155 # acceptremote is True because we don't want prompts in the middle of
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
156 # our benchmark
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
157 merge.calculateupdates(repo, wctx, rctx, ancestor, False, False, False,
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
158 acceptremote=True)
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
159 timer(d)
c760acc6f69d perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents: 18644
diff changeset
160
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
161 @command('perfmanifest')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
162 def perfmanifest(ui, repo):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
163 def d():
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
164 t = repo.manifest.tip()
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
165 m = repo.manifest.read(t)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
166 repo.manifest.mapcache = None
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
167 repo.manifest._cache = None
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
168 timer(d)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
169
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
170 @command('perfchangeset')
16262
bf7a6c3b2a4a perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents: 16260
diff changeset
171 def perfchangeset(ui, repo, rev):
bf7a6c3b2a4a perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents: 16260
diff changeset
172 n = repo[rev].node()
bf7a6c3b2a4a perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents: 16260
diff changeset
173 def d():
bf7a6c3b2a4a perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents: 16260
diff changeset
174 c = repo.changelog.read(n)
16266
77d56a5e74a5 perf: add a changeset test
Matt Mackall <mpm@selenic.com>
parents: 16262
diff changeset
175 #repo.changelog._cache = None
16262
bf7a6c3b2a4a perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents: 16260
diff changeset
176 timer(d)
bf7a6c3b2a4a perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents: 16260
diff changeset
177
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
178 @command('perfindex')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
179 def perfindex(ui, repo):
13255
2696730ca233 perf: make perfindex results useful on hg with lazyparser
Matt Mackall <mpm@selenic.com>
parents: 13254
diff changeset
180 import mercurial.revlog
13277
9f707b297b0f perf: restore lazyindex hack
Matt Mackall <mpm@selenic.com>
parents: 13262
diff changeset
181 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
182 n = repo["tip"].node()
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
183 def d():
16260
33fcad3cfbbc perf: tweak tests for testing index performance improvements
Matt Mackall <mpm@selenic.com>
parents: 14671
diff changeset
184 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
185 cl.rev(n)
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
186 timer(d)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
187
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
188 @command('perfstartup')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
189 def perfstartup(ui, repo):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
190 cmd = sys.argv[0]
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
191 def d():
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
192 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
193 timer(d)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
194
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
195 @command('perfparents')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
196 def perfparents(ui, repo):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
197 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
198 def d():
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
199 for n in nl:
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
200 repo.changelog.parents(n)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
201 timer(d)
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
202
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
203 @command('perflookup')
7366
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
204 def perflookup(ui, repo, rev):
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
205 timer(lambda: len(repo.lookup(rev)))
eb240755386d Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
206
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
207 @command('perfrevrange')
16858
fdf99e0f60f3 perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents: 16802
diff changeset
208 def perfrevrange(ui, repo, *specs):
fdf99e0f60f3 perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents: 16802
diff changeset
209 revrange = scmutil.revrange
fdf99e0f60f3 perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents: 16802
diff changeset
210 timer(lambda: len(revrange(repo, specs)))
fdf99e0f60f3 perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents: 16802
diff changeset
211
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
212 @command('perfnodelookup')
16309
e0c1b3ef7c36 perf: node lookup
Matt Mackall <mpm@selenic.com>
parents: 16266
diff changeset
213 def perfnodelookup(ui, repo, rev):
e0c1b3ef7c36 perf: node lookup
Matt Mackall <mpm@selenic.com>
parents: 16266
diff changeset
214 import mercurial.revlog
e0c1b3ef7c36 perf: node lookup
Matt Mackall <mpm@selenic.com>
parents: 16266
diff changeset
215 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
e0c1b3ef7c36 perf: node lookup
Matt Mackall <mpm@selenic.com>
parents: 16266
diff changeset
216 n = repo[rev].node()
16414
e8d37b78acfb parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents: 16403
diff changeset
217 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
218 def d():
e8d37b78acfb parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents: 16403
diff changeset
219 cl.rev(n)
16785
1dc08dc63c09 perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents: 16689
diff changeset
220 clearcaches(cl)
16414
e8d37b78acfb parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents: 16403
diff changeset
221 timer(d)
e8d37b78acfb parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents: 16403
diff changeset
222
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
223 @command('perflog',
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
224 [('', 'rename', False, 'ask log to follow renames')])
9932
2fcbef9a349a perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents: 9826
diff changeset
225 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
226 ui.pushbuffer()
9932
2fcbef9a349a perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents: 9826
diff changeset
227 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
228 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
229 ui.popbuffer()
f680a1bd679b contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7366
diff changeset
230
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
231 @command('perftemplating')
7872
f680a1bd679b contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7366
diff changeset
232 def perftemplating(ui, repo):
f680a1bd679b contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7366
diff changeset
233 ui.pushbuffer()
f680a1bd679b contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7366
diff changeset
234 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
235 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
236 ' {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
237 ui.popbuffer()
f680a1bd679b contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents: 7366
diff changeset
238
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
239 @command('perfcca')
16386
ccc173d0914e perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents: 16309
diff changeset
240 def perfcca(ui, repo):
17216
01c1ee4bd1dd perf: fix perfcca to work with new casecollisionauditor interface
Joshua Redstone <joshua.redstone@fb.com>
parents: 16866
diff changeset
241 timer(lambda: scmutil.casecollisionauditor(ui, False, repo.dirstate))
16386
ccc173d0914e perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents: 16309
diff changeset
242
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
243 @command('perffncacheload')
16403
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
244 def perffncacheload(ui, repo):
17780
769f66861eb8 perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents: 17553
diff changeset
245 s = repo.store
16403
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
246 def d():
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
247 s.fncache._load()
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
248 timer(d)
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
249
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
250 @command('perffncachewrite')
16403
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
251 def perffncachewrite(ui, repo):
17780
769f66861eb8 perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents: 17553
diff changeset
252 s = repo.store
16403
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
253 s.fncache._load()
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
254 def d():
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
255 s.fncache._dirty = True
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
256 s.fncache.write()
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
257 timer(d)
efae1fea4bbd perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents: 16386
diff changeset
258
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
259 @command('perffncacheencode')
17553
5ab863922e0f perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents: 17216
diff changeset
260 def perffncacheencode(ui, repo):
17780
769f66861eb8 perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents: 17553
diff changeset
261 s = repo.store
17553
5ab863922e0f perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents: 17216
diff changeset
262 s.fncache._load()
5ab863922e0f perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents: 17216
diff changeset
263 def d():
5ab863922e0f perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents: 17216
diff changeset
264 for p in s.fncache.entries:
5ab863922e0f perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents: 17216
diff changeset
265 s.encode(p)
5ab863922e0f perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents: 17216
diff changeset
266 timer(d)
5ab863922e0f perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents: 17216
diff changeset
267
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
268 @command('perfdiffwd')
9826
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
269 def perfdiffwd(ui, repo):
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
270 """Profile diff of working directory changes"""
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
271 options = {
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
272 'w': 'ignore_all_space',
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
273 'b': 'ignore_space_change',
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
274 'B': 'ignore_blank_lines',
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
275 }
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
276
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
277 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
278 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
279 def d():
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
280 ui.pushbuffer()
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
281 commands.diff(ui, repo, **opts)
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
282 ui.popbuffer()
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
283 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
284 timer(d, title)
d768614578dd contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents: 9146
diff changeset
285
18237
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
286 @command('perfrevlog',
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
287 [('d', 'dist', 100, 'distance between the revisions')],
4132dc9bd5c4 perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18236
diff changeset
288 "[INDEXFILE]")
11694
bf49d48e4602 perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 10493
diff changeset
289 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
290 from mercurial import revlog
bf49d48e4602 perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 10493
diff changeset
291 dist = opts['dist']
bf49d48e4602 perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 10493
diff changeset
292 def d():
bf49d48e4602 perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 10493
diff changeset
293 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
294 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
295 r.revision(r.node(x))
bf49d48e4602 perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 10493
diff changeset
296
bf49d48e4602 perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 10493
diff changeset
297 timer(d)
bf49d48e4602 perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents: 10493
diff changeset
298
18239
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
299 @command('perfrevset',
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
300 [('C', 'clear', False, 'clear volatile cache between each call.')],
18238
1f991e625d01 perftest: document the perfrevset command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18237
diff changeset
301 "REVSET")
18239
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
302 def perfrevset(ui, repo, expr, clear=False):
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
303 """benchmark the execution time of a revset
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
304
18644
3e92772d5383 spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents: 18304
diff changeset
305 Use the --clean option if need to evaluate the impact of build volatile
18239
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
306 revisions set cache on the revset execution. Volatile cache hold filtered
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
307 and obsolete related cache."""
18062
1471f5e83686 perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents: 18033
diff changeset
308 def d():
18239
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
309 if clear:
a95f1d619bb7 perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18238
diff changeset
310 repo.invalidatevolatilesets()
18062
1471f5e83686 perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents: 18033
diff changeset
311 repo.revs(expr)
1471f5e83686 perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents: 18033
diff changeset
312 timer(d)
18240
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
313
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
314 @command('perfvolatilesets')
18241
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
315 def perfvolatilesets(ui, repo, *names):
18240
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
316 """benchmark the computation of various volatile set
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
317
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
318 Volatile set computes element related to filtering and obsolescence."""
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
319 repo = repo.unfiltered()
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
320
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
321 def getobs(name):
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
322 def d():
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
323 repo.invalidatevolatilesets()
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
324 obsolete.getrevs(repo, name)
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
325 return d
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
326
18241
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
327 allobs = sorted(obsolete.cachefuncs)
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
328 if names:
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
329 allobs = [n for n in allobs if n in names]
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
330
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
331 for name in allobs:
18240
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
332 timer(getobs(name), title=name)
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
333
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
334 def getfiltered(name):
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
335 def d():
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
336 repo.invalidatevolatilesets()
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
337 repoview.filteredrevs(repo, name)
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
338 return d
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
339
18241
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
340 allfilter = sorted(repoview.filtertable)
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
341 if names:
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
342 allfilter = [n for n in allfilter if n in names]
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
343
f5ed27c51995 perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18240
diff changeset
344 for name in allfilter:
18240
a8318715d8bb perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18239
diff changeset
345 timer(getfiltered(name), title=name)
18304
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
346
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
347 @command('perfbranchmap',
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
348 [('f', 'full', False,
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
349 'Includes build time of subset'),
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
350 ])
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
351 def perfbranchmap(ui, repo, full=False):
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
352 """benchmark the update of a branchmap
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
353
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
354 This benchmarks the full repo.branchmap() call with read and write disabled
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
355 """
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
356 def getbranchmap(filtername):
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
357 """generate a benchmark function for the filtername"""
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
358 if filtername is None:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
359 view = repo
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
360 else:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
361 view = repo.filtered(filtername)
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
362 def d():
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
363 if full:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
364 view._branchcaches.clear()
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
365 else:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
366 view._branchcaches.pop(filtername, None)
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
367 view.branchmap()
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
368 return d
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
369 # add filter in smaller subset to bigger subset
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
370 possiblefilters = set(repoview.filtertable)
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
371 allfilters = []
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
372 while possiblefilters:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
373 for name in possiblefilters:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
374 subset = repoview.subsettable.get(name)
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
375 if subset not in possiblefilters:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
376 break
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
377 else:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
378 assert False, 'subset cycle %s!' % possiblefilters
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
379 allfilters.append(name)
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
380 possiblefilters.remove(name)
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
381
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
382 # warm the cache
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
383 if not full:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
384 for name in allfilters:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
385 repo.filtered(name).branchmap()
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
386 # add unfiltered
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
387 allfilters.append(None)
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
388 oldread = branchmap.read
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
389 oldwrite = branchmap.branchcache.write
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
390 try:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
391 branchmap.read = lambda repo: None
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
392 branchmap.write = lambda repo: None
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
393 for name in allfilters:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
394 timer(getbranchmap(name), title=str(name))
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
395 finally:
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
396 branchmap.read = oldread
9b6ae29d4801 perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18241
diff changeset
397 branchmap.branchcache.write = oldwrite