Show More
@@ -4,6 +4,9 b'' | |||||
4 | from mercurial import cmdutil, scmutil, util, match, commands |
|
4 | from mercurial import cmdutil, scmutil, util, match, commands | |
5 | import time, os, sys |
|
5 | import time, os, sys | |
6 |
|
6 | |||
|
7 | cmdtable = {} | |||
|
8 | command = cmdutil.command(cmdtable) | |||
|
9 | ||||
7 | def timer(func, title=None): |
|
10 | def timer(func, title=None): | |
8 | results = [] |
|
11 | results = [] | |
9 | begin = time.time() |
|
12 | begin = time.time() | |
@@ -29,6 +32,7 b' def timer(func, title=None):' | |||||
29 | sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n" |
|
32 | sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n" | |
30 | % (m[0], m[1] + m[2], m[1], m[2], count)) |
|
33 | % (m[0], m[1] + m[2], m[1], m[2], count)) | |
31 |
|
34 | |||
|
35 | @command('perfwalk') | |||
32 | def perfwalk(ui, repo, *pats): |
|
36 | def perfwalk(ui, repo, *pats): | |
33 | try: |
|
37 | try: | |
34 | m = scmutil.match(repo[None], pats, {}) |
|
38 | m = scmutil.match(repo[None], pats, {}) | |
@@ -40,6 +44,9 b' def perfwalk(ui, repo, *pats):' | |||||
40 | except Exception: |
|
44 | except Exception: | |
41 | timer(lambda: len(list(cmdutil.walk(repo, pats, {})))) |
|
45 | timer(lambda: len(list(cmdutil.walk(repo, pats, {})))) | |
42 |
|
46 | |||
|
47 | @command('perfstatus', | |||
|
48 | [('u', 'unknown', False, | |||
|
49 | 'ask status to look for unknown files')]) | |||
43 | def perfstatus(ui, repo, **opts): |
|
50 | def perfstatus(ui, repo, **opts): | |
44 | #m = match.always(repo.root, repo.getcwd()) |
|
51 | #m = match.always(repo.root, repo.getcwd()) | |
45 | #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, |
|
52 | #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, | |
@@ -55,6 +62,7 b' def clearcaches(cl):' | |||||
55 | cl._nodecache = {nullid: nullrev} |
|
62 | cl._nodecache = {nullid: nullrev} | |
56 | cl._nodepos = None |
|
63 | cl._nodepos = None | |
57 |
|
64 | |||
|
65 | @command('perfheads') | |||
58 | def perfheads(ui, repo): |
|
66 | def perfheads(ui, repo): | |
59 | cl = repo.changelog |
|
67 | cl = repo.changelog | |
60 | def d(): |
|
68 | def d(): | |
@@ -62,6 +70,7 b' def perfheads(ui, repo):' | |||||
62 | clearcaches(cl) |
|
70 | clearcaches(cl) | |
63 | timer(d) |
|
71 | timer(d) | |
64 |
|
72 | |||
|
73 | @command('perftags') | |||
65 | def perftags(ui, repo): |
|
74 | def perftags(ui, repo): | |
66 | import mercurial.changelog, mercurial.manifest |
|
75 | import mercurial.changelog, mercurial.manifest | |
67 | def t(): |
|
76 | def t(): | |
@@ -71,6 +80,7 b' def perftags(ui, repo):' | |||||
71 | return len(repo.tags()) |
|
80 | return len(repo.tags()) | |
72 | timer(t) |
|
81 | timer(t) | |
73 |
|
82 | |||
|
83 | @command('perfancestors') | |||
74 | def perfancestors(ui, repo): |
|
84 | def perfancestors(ui, repo): | |
75 | heads = repo.changelog.headrevs() |
|
85 | heads = repo.changelog.headrevs() | |
76 | def d(): |
|
86 | def d(): | |
@@ -78,6 +88,7 b' def perfancestors(ui, repo):' | |||||
78 | pass |
|
88 | pass | |
79 | timer(d) |
|
89 | timer(d) | |
80 |
|
90 | |||
|
91 | @command('perfancestorset') | |||
81 | def perfancestorset(ui, repo, revset): |
|
92 | def perfancestorset(ui, repo, revset): | |
82 | revs = repo.revs(revset) |
|
93 | revs = repo.revs(revset) | |
83 | heads = repo.changelog.headrevs() |
|
94 | heads = repo.changelog.headrevs() | |
@@ -87,6 +98,7 b' def perfancestorset(ui, repo, revset):' | |||||
87 | rev in s |
|
98 | rev in s | |
88 | timer(d) |
|
99 | timer(d) | |
89 |
|
100 | |||
|
101 | @command('perfdirstate') | |||
90 | def perfdirstate(ui, repo): |
|
102 | def perfdirstate(ui, repo): | |
91 | "a" in repo.dirstate |
|
103 | "a" in repo.dirstate | |
92 | def d(): |
|
104 | def d(): | |
@@ -94,6 +106,7 b' def perfdirstate(ui, repo):' | |||||
94 | "a" in repo.dirstate |
|
106 | "a" in repo.dirstate | |
95 | timer(d) |
|
107 | timer(d) | |
96 |
|
108 | |||
|
109 | @command('perfdirstatedirs') | |||
97 | def perfdirstatedirs(ui, repo): |
|
110 | def perfdirstatedirs(ui, repo): | |
98 | "a" in repo.dirstate |
|
111 | "a" in repo.dirstate | |
99 | def d(): |
|
112 | def d(): | |
@@ -101,6 +114,7 b' def perfdirstatedirs(ui, repo):' | |||||
101 | del repo.dirstate._dirs |
|
114 | del repo.dirstate._dirs | |
102 | timer(d) |
|
115 | timer(d) | |
103 |
|
116 | |||
|
117 | @command('perfdirstatewrite') | |||
104 | def perfdirstatewrite(ui, repo): |
|
118 | def perfdirstatewrite(ui, repo): | |
105 | ds = repo.dirstate |
|
119 | ds = repo.dirstate | |
106 | "a" in ds |
|
120 | "a" in ds | |
@@ -109,6 +123,7 b' def perfdirstatewrite(ui, repo):' | |||||
109 | ds.write() |
|
123 | ds.write() | |
110 | timer(d) |
|
124 | timer(d) | |
111 |
|
125 | |||
|
126 | @command('perfmanifest') | |||
112 | def perfmanifest(ui, repo): |
|
127 | def perfmanifest(ui, repo): | |
113 | def d(): |
|
128 | def d(): | |
114 | t = repo.manifest.tip() |
|
129 | t = repo.manifest.tip() | |
@@ -117,6 +132,7 b' def perfmanifest(ui, repo):' | |||||
117 | repo.manifest._cache = None |
|
132 | repo.manifest._cache = None | |
118 | timer(d) |
|
133 | timer(d) | |
119 |
|
134 | |||
|
135 | @command('perfchangeset') | |||
120 | def perfchangeset(ui, repo, rev): |
|
136 | def perfchangeset(ui, repo, rev): | |
121 | n = repo[rev].node() |
|
137 | n = repo[rev].node() | |
122 | def d(): |
|
138 | def d(): | |
@@ -124,6 +140,7 b' def perfchangeset(ui, repo, rev):' | |||||
124 | #repo.changelog._cache = None |
|
140 | #repo.changelog._cache = None | |
125 | timer(d) |
|
141 | timer(d) | |
126 |
|
142 | |||
|
143 | @command('perfindex') | |||
127 | def perfindex(ui, repo): |
|
144 | def perfindex(ui, repo): | |
128 | import mercurial.revlog |
|
145 | import mercurial.revlog | |
129 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
|
146 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg | |
@@ -133,12 +150,14 b' def perfindex(ui, repo):' | |||||
133 | cl.rev(n) |
|
150 | cl.rev(n) | |
134 | timer(d) |
|
151 | timer(d) | |
135 |
|
152 | |||
|
153 | @command('perfstartup') | |||
136 | def perfstartup(ui, repo): |
|
154 | def perfstartup(ui, repo): | |
137 | cmd = sys.argv[0] |
|
155 | cmd = sys.argv[0] | |
138 | def d(): |
|
156 | def d(): | |
139 | os.system("HGRCPATH= %s version -q > /dev/null" % cmd) |
|
157 | os.system("HGRCPATH= %s version -q > /dev/null" % cmd) | |
140 | timer(d) |
|
158 | timer(d) | |
141 |
|
159 | |||
|
160 | @command('perfparents') | |||
142 | def perfparents(ui, repo): |
|
161 | def perfparents(ui, repo): | |
143 | nl = [repo.changelog.node(i) for i in xrange(1000)] |
|
162 | nl = [repo.changelog.node(i) for i in xrange(1000)] | |
144 | def d(): |
|
163 | def d(): | |
@@ -146,13 +165,16 b' def perfparents(ui, repo):' | |||||
146 | repo.changelog.parents(n) |
|
165 | repo.changelog.parents(n) | |
147 | timer(d) |
|
166 | timer(d) | |
148 |
|
167 | |||
|
168 | @command('perflookup') | |||
149 | def perflookup(ui, repo, rev): |
|
169 | def perflookup(ui, repo, rev): | |
150 | timer(lambda: len(repo.lookup(rev))) |
|
170 | timer(lambda: len(repo.lookup(rev))) | |
151 |
|
171 | |||
|
172 | @command('perfrevrange') | |||
152 | def perfrevrange(ui, repo, *specs): |
|
173 | def perfrevrange(ui, repo, *specs): | |
153 | revrange = scmutil.revrange |
|
174 | revrange = scmutil.revrange | |
154 | timer(lambda: len(revrange(repo, specs))) |
|
175 | timer(lambda: len(revrange(repo, specs))) | |
155 |
|
176 | |||
|
177 | @command('perfnodelookup') | |||
156 | def perfnodelookup(ui, repo, rev): |
|
178 | def perfnodelookup(ui, repo, rev): | |
157 | import mercurial.revlog |
|
179 | import mercurial.revlog | |
158 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
|
180 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg | |
@@ -163,12 +185,15 b' def perfnodelookup(ui, repo, rev):' | |||||
163 | clearcaches(cl) |
|
185 | clearcaches(cl) | |
164 | timer(d) |
|
186 | timer(d) | |
165 |
|
187 | |||
|
188 | @command('perflog', | |||
|
189 | [('', 'rename', False, 'ask log to follow renames')]) | |||
166 | def perflog(ui, repo, **opts): |
|
190 | def perflog(ui, repo, **opts): | |
167 | ui.pushbuffer() |
|
191 | ui.pushbuffer() | |
168 | timer(lambda: commands.log(ui, repo, rev=[], date='', user='', |
|
192 | timer(lambda: commands.log(ui, repo, rev=[], date='', user='', | |
169 | copies=opts.get('rename'))) |
|
193 | copies=opts.get('rename'))) | |
170 | ui.popbuffer() |
|
194 | ui.popbuffer() | |
171 |
|
195 | |||
|
196 | @command('perftemplating') | |||
172 | def perftemplating(ui, repo): |
|
197 | def perftemplating(ui, repo): | |
173 | ui.pushbuffer() |
|
198 | ui.pushbuffer() | |
174 | timer(lambda: commands.log(ui, repo, rev=[], date='', user='', |
|
199 | timer(lambda: commands.log(ui, repo, rev=[], date='', user='', | |
@@ -176,15 +201,18 b' def perftemplating(ui, repo):' | |||||
176 | ' {author|person}: {desc|firstline}\n')) |
|
201 | ' {author|person}: {desc|firstline}\n')) | |
177 | ui.popbuffer() |
|
202 | ui.popbuffer() | |
178 |
|
203 | |||
|
204 | @command('perfcca') | |||
179 | def perfcca(ui, repo): |
|
205 | def perfcca(ui, repo): | |
180 | timer(lambda: scmutil.casecollisionauditor(ui, False, repo.dirstate)) |
|
206 | timer(lambda: scmutil.casecollisionauditor(ui, False, repo.dirstate)) | |
181 |
|
207 | |||
|
208 | @command('perffncacheload') | |||
182 | def perffncacheload(ui, repo): |
|
209 | def perffncacheload(ui, repo): | |
183 | s = repo.store |
|
210 | s = repo.store | |
184 | def d(): |
|
211 | def d(): | |
185 | s.fncache._load() |
|
212 | s.fncache._load() | |
186 | timer(d) |
|
213 | timer(d) | |
187 |
|
214 | |||
|
215 | @command('perffncachewrite') | |||
188 | def perffncachewrite(ui, repo): |
|
216 | def perffncachewrite(ui, repo): | |
189 | s = repo.store |
|
217 | s = repo.store | |
190 | s.fncache._load() |
|
218 | s.fncache._load() | |
@@ -193,6 +221,7 b' def perffncachewrite(ui, repo):' | |||||
193 | s.fncache.write() |
|
221 | s.fncache.write() | |
194 | timer(d) |
|
222 | timer(d) | |
195 |
|
223 | |||
|
224 | @command('perffncacheencode') | |||
196 | def perffncacheencode(ui, repo): |
|
225 | def perffncacheencode(ui, repo): | |
197 | s = repo.store |
|
226 | s = repo.store | |
198 | s.fncache._load() |
|
227 | s.fncache._load() | |
@@ -201,6 +230,7 b' def perffncacheencode(ui, repo):' | |||||
201 | s.encode(p) |
|
230 | s.encode(p) | |
202 | timer(d) |
|
231 | timer(d) | |
203 |
|
232 | |||
|
233 | @command('perfdiffwd') | |||
204 | def perfdiffwd(ui, repo): |
|
234 | def perfdiffwd(ui, repo): | |
205 | """Profile diff of working directory changes""" |
|
235 | """Profile diff of working directory changes""" | |
206 | options = { |
|
236 | options = { | |
@@ -218,6 +248,9 b' def perfdiffwd(ui, repo):' | |||||
218 | title = 'diffopts: %s' % (diffopt and ('-' + diffopt) or 'none') |
|
248 | title = 'diffopts: %s' % (diffopt and ('-' + diffopt) or 'none') | |
219 | timer(d, title) |
|
249 | timer(d, title) | |
220 |
|
250 | |||
|
251 | @command('perfrevlog', | |||
|
252 | [('d', 'dist', 100, 'distance between the revisions')], | |||
|
253 | "[INDEXFILE]") | |||
221 | def perfrevlog(ui, repo, file_, **opts): |
|
254 | def perfrevlog(ui, repo, file_, **opts): | |
222 | from mercurial import revlog |
|
255 | from mercurial import revlog | |
223 | dist = opts['dist'] |
|
256 | dist = opts['dist'] | |
@@ -228,41 +261,8 b' def perfrevlog(ui, repo, file_, **opts):' | |||||
228 |
|
261 | |||
229 | timer(d) |
|
262 | timer(d) | |
230 |
|
263 | |||
|
264 | @command('perfrevset') | |||
231 | def perfrevset(ui, repo, expr): |
|
265 | def perfrevset(ui, repo, expr): | |
232 | def d(): |
|
266 | def d(): | |
233 | repo.revs(expr) |
|
267 | repo.revs(expr) | |
234 | timer(d) |
|
268 | timer(d) | |
235 |
|
||||
236 | cmdtable = { |
|
|||
237 | 'perfcca': (perfcca, []), |
|
|||
238 | 'perffncacheload': (perffncacheload, []), |
|
|||
239 | 'perffncachewrite': (perffncachewrite, []), |
|
|||
240 | 'perffncacheencode': (perffncacheencode, []), |
|
|||
241 | 'perflookup': (perflookup, []), |
|
|||
242 | 'perfrevrange': (perfrevrange, []), |
|
|||
243 | 'perfnodelookup': (perfnodelookup, []), |
|
|||
244 | 'perfparents': (perfparents, []), |
|
|||
245 | 'perfstartup': (perfstartup, []), |
|
|||
246 | 'perfstatus': (perfstatus, |
|
|||
247 | [('u', 'unknown', False, |
|
|||
248 | 'ask status to look for unknown files')]), |
|
|||
249 | 'perfwalk': (perfwalk, []), |
|
|||
250 | 'perfmanifest': (perfmanifest, []), |
|
|||
251 | 'perfchangeset': (perfchangeset, []), |
|
|||
252 | 'perfindex': (perfindex, []), |
|
|||
253 | 'perfheads': (perfheads, []), |
|
|||
254 | 'perftags': (perftags, []), |
|
|||
255 | 'perfancestors': (perfancestors, []), |
|
|||
256 | 'perfancestorset': (perfancestorset, [], "REVSET"), |
|
|||
257 | 'perfdirstate': (perfdirstate, []), |
|
|||
258 | 'perfdirstatedirs': (perfdirstate, []), |
|
|||
259 | 'perfdirstatewrite': (perfdirstatewrite, []), |
|
|||
260 | 'perflog': (perflog, |
|
|||
261 | [('', 'rename', False, 'ask log to follow renames')]), |
|
|||
262 | 'perftemplating': (perftemplating, []), |
|
|||
263 | 'perfdiffwd': (perfdiffwd, []), |
|
|||
264 | 'perfrevlog': (perfrevlog, |
|
|||
265 | [('d', 'dist', 100, 'distance between the revisions')], |
|
|||
266 | "[INDEXFILE]"), |
|
|||
267 | 'perfrevset': (perfrevset, [], "REVSET") |
|
|||
268 | } |
|
General Comments 0
You need to be logged in to leave comments.
Login now