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