author | Pradeepkumar Gayam <in3xes@gmail.com> |
Tue, 17 Aug 2010 17:56:26 +0530 | |
changeset 11920 | d0a7e700b5d1 |
parent 11713 | 57a8894e3f75 |
child 13253 | 61c9bc3da402 |
permissions | -rw-r--r-- |
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 |
|
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
4 |
from mercurial import cmdutil, 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 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
11 |
while 1: |
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: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 |
m = cmdutil.match(repo, 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)))) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
36 |
except: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 |
try: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 |
m = cmdutil.match(repo, 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)])) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
40 |
except: |
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()) |
10493
283f3b413f19
regression: missing arg from 24ce8f0c0a39 dirstate.{walk,status} changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
45 |
#timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, False)))) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
46 |
timer(lambda: sum(map(len, repo.status()))) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
47 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
48 |
def perfheads(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 |
timer(lambda: len(repo.changelog.heads())) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
50 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
51 |
def perftags(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
52 |
import mercurial.changelog, mercurial.manifest |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
53 |
def t(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
54 |
repo.changelog = mercurial.changelog.changelog(repo.sopener) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
55 |
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
|
56 |
repo._tags = None |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
57 |
return len(repo.tags()) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
58 |
timer(t) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
59 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
60 |
def perfdirstate(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
61 |
"a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
62 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
63 |
repo.dirstate.invalidate() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
64 |
"a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
65 |
timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
66 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
67 |
def perfdirstatedirs(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
68 |
"a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
69 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
70 |
"a" in repo.dirstate._dirs |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
71 |
del repo.dirstate._dirs |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
72 |
timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
73 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
74 |
def perfmanifest(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
75 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
76 |
t = repo.manifest.tip() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
77 |
m = repo.manifest.read(t) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
78 |
repo.manifest.mapcache = None |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
79 |
repo.manifest._cache = None |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
80 |
timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
81 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
82 |
def perfindex(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
83 |
import mercurial.changelog |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
84 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
85 |
t = repo.changelog.tip() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
86 |
repo.changelog = mercurial.changelog.changelog(repo.sopener) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
87 |
repo.changelog._loadindexmap() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
88 |
timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
89 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
90 |
def perfstartup(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
91 |
cmd = sys.argv[0] |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
92 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
93 |
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
|
94 |
timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
95 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
96 |
def perfparents(ui, repo): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
97 |
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
|
98 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
99 |
for n in nl: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 |
repo.changelog.parents(n) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
101 |
timer(d) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
102 |
|
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
103 |
def perflookup(ui, repo, rev): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 |
timer(lambda: len(repo.lookup(rev))) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
105 |
|
9932
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
106 |
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
|
107 |
ui.pushbuffer() |
9932
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
108 |
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
|
109 |
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
|
110 |
ui.popbuffer() |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
111 |
|
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
112 |
def perftemplating(ui, repo): |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
113 |
ui.pushbuffer() |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
114 |
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
|
115 |
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
|
116 |
' {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
|
117 |
ui.popbuffer() |
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
118 |
|
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
119 |
def perfdiffwd(ui, repo): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
120 |
"""Profile diff of working directory changes""" |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
121 |
options = { |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
122 |
'w': 'ignore_all_space', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
123 |
'b': 'ignore_space_change', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
124 |
'B': 'ignore_blank_lines', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
125 |
} |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
126 |
|
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
127 |
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
|
128 |
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
|
129 |
def d(): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
130 |
ui.pushbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
131 |
commands.diff(ui, repo, **opts) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
132 |
ui.popbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
133 |
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
|
134 |
timer(d, title) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
135 |
|
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
136 |
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
|
137 |
from mercurial import revlog |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
138 |
dist = opts['dist'] |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
139 |
def d(): |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
140 |
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
|
141 |
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
|
142 |
r.revision(r.node(x)) |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
143 |
|
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
144 |
timer(d) |
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
145 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
146 |
cmdtable = { |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
147 |
'perflookup': (perflookup, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
148 |
'perfparents': (perfparents, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
149 |
'perfstartup': (perfstartup, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
150 |
'perfstatus': (perfstatus, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
151 |
'perfwalk': (perfwalk, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
152 |
'perfmanifest': (perfmanifest, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
153 |
'perfindex': (perfindex, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
154 |
'perfheads': (perfheads, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
155 |
'perftags': (perftags, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
156 |
'perfdirstate': (perfdirstate, []), |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
157 |
'perfdirstatedirs': (perfdirstate, []), |
9932
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
158 |
'perflog': (perflog, |
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
159 |
[('', '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
|
160 |
'perftemplating': (perftemplating, []), |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
161 |
'perfdiffwd': (perfdiffwd, []), |
11713
57a8894e3f75
perf: break down long line
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11694
diff
changeset
|
162 |
'perfrevlog': (perfrevlog, |
57a8894e3f75
perf: break down long line
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11694
diff
changeset
|
163 |
[('d', 'dist', 100, 'distance between the revisions')], |
57a8894e3f75
perf: break down long line
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11694
diff
changeset
|
164 |
"[INDEXFILE]"), |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
165 |
} |