author | Martin von Zweigbergk <martinvonz@google.com> |
Tue, 30 May 2017 10:27:20 -0700 | |
changeset 32592 | c37ca35b8450 |
parent 32532 | e4f514627514 |
child 32710 | 326c0e2c1a1d |
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 |
|
29493
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
4 |
# "historical portability" policy of perf.py: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
5 |
# |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
6 |
# We have to do: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
7 |
# - make perf.py "loadable" with as wide Mercurial version as possible |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
8 |
# This doesn't mean that perf commands work correctly with that Mercurial. |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
9 |
# BTW, perf.py itself has been available since 1.1 (or eb240755386d). |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
10 |
# - make historical perf command work correctly with as wide Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
11 |
# version as possible |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
12 |
# |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
13 |
# We have to do, if possible with reasonable cost: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
14 |
# - make recent perf command for historical feature work correctly |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
15 |
# with early Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
16 |
# |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
17 |
# We don't have to do: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
18 |
# - make perf command for recent feature work correctly with early |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
19 |
# Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
20 |
|
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
21 |
from __future__ import absolute_import |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
22 |
import functools |
31397
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30977
diff
changeset
|
23 |
import gc |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
24 |
import os |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
25 |
import random |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
26 |
import struct |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
27 |
import sys |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
28 |
import time |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
29 |
from mercurial import ( |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
30 |
changegroup, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
31 |
cmdutil, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
32 |
commands, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
33 |
copies, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
34 |
error, |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
35 |
extensions, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
36 |
mdiff, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
37 |
merge, |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
38 |
revlog, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
39 |
util, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
40 |
) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
41 |
|
29494
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
42 |
# for "historical portability": |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
43 |
# try to import modules separately (in dict order), and ignore |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
44 |
# failure, because these aren't available with early Mercurial |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
45 |
try: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
46 |
from mercurial import branchmap # since 2.5 (or bcee63733aad) |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
47 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
48 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
49 |
try: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
50 |
from mercurial import obsolete # since 2.3 (or ad0d6c2b3279) |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
51 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
52 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
53 |
try: |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
54 |
from mercurial import registrar # since 3.7 (or 37d50250b696) |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
55 |
dir(registrar) # forcibly load it |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
56 |
except ImportError: |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
57 |
registrar = None |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
58 |
try: |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
59 |
from mercurial import repoview # since 2.5 (or 3a6ddacb7198) |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
60 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
61 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
62 |
try: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
63 |
from mercurial import scmutil # since 1.9 (or 8b252e826c68) |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
64 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
65 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
66 |
|
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
67 |
# for "historical portability": |
29494
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
68 |
# define util.safehasattr forcibly, because util.safehasattr has been |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
69 |
# available since 1.9.3 (or 94b200a11cf7) |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
70 |
_undefined = object() |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
71 |
def safehasattr(thing, attr): |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
72 |
return getattr(thing, attr, _undefined) is not _undefined |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
73 |
setattr(util, 'safehasattr', safehasattr) |
3b5389ef5cfe
perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29493
diff
changeset
|
74 |
|
29496
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
75 |
# for "historical portability": |
31823
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
76 |
# define util.timer forcibly, because util.timer has been available |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
77 |
# since ae5d60bb70c9 |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
78 |
if safehasattr(time, 'perf_counter'): |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
79 |
util.timer = time.perf_counter |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
80 |
elif os.name == 'nt': |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
81 |
util.timer = time.clock |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
82 |
else: |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
83 |
util.timer = time.time |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
84 |
|
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
85 |
# for "historical portability": |
29496
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
86 |
# use locally defined empty option list, if formatteropts isn't |
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
87 |
# available, because commands.formatteropts has been available since |
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
88 |
# 3.2 (or 7a7eed5176a4), even though formatting itself has been |
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
89 |
# available since 2.2 (or ae5f92e154d3) |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
90 |
formatteropts = getattr(cmdutil, "formatteropts", |
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
91 |
getattr(commands, "formatteropts", [])) |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
92 |
|
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
93 |
# for "historical portability": |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
94 |
# use locally defined option list, if debugrevlogopts isn't available, |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
95 |
# because commands.debugrevlogopts has been available since 3.7 (or |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
96 |
# 5606f7d0d063), even though cmdutil.openrevlog() has been available |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
97 |
# since 1.9 (or a79fea6b3e77). |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
98 |
revlogopts = getattr(cmdutil, "debugrevlogopts", |
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
99 |
getattr(commands, "debugrevlogopts", [ |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
100 |
('c', 'changelog', False, ('open changelog')), |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
101 |
('m', 'manifest', False, ('open manifest')), |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
102 |
('', 'dir', False, ('open directory manifest')), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
103 |
])) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
104 |
|
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
105 |
cmdtable = {} |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
106 |
|
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
107 |
# for "historical portability": |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
108 |
# define parsealiases locally, because cmdutil.parsealiases has been |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
109 |
# available since 1.5 (or 6252852b4332) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
110 |
def parsealiases(cmd): |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
111 |
return cmd.lstrip("^").split("|") |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
112 |
|
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
113 |
if safehasattr(registrar, 'command'): |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
114 |
command = registrar.command(cmdtable) |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
115 |
elif safehasattr(cmdutil, 'command'): |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
116 |
import inspect |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
117 |
command = cmdutil.command(cmdtable) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
118 |
if 'norepo' not in inspect.getargspec(command)[0]: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
119 |
# for "historical portability": |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
120 |
# wrap original cmdutil.command, because "norepo" option has |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
121 |
# been available since 3.1 (or 75a96326cecb) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
122 |
_command = command |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
123 |
def command(name, options=(), synopsis=None, norepo=False): |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
124 |
if norepo: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
125 |
commands.norepo += ' %s' % ' '.join(parsealiases(name)) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
126 |
return _command(name, list(options), synopsis) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
127 |
else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
128 |
# for "historical portability": |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
129 |
# define "@command" annotation locally, because cmdutil.command |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
130 |
# has been available since 1.9 (or 2daa5179e73f) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
131 |
def command(name, options=(), synopsis=None, norepo=False): |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
132 |
def decorator(func): |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
133 |
if synopsis: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
134 |
cmdtable[name] = func, list(options), synopsis |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
135 |
else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
136 |
cmdtable[name] = func, list(options) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
137 |
if norepo: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
138 |
commands.norepo += ' %s' % ' '.join(parsealiases(name)) |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
139 |
return func |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
140 |
return decorator |
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
141 |
|
27307 | 142 |
def getlen(ui): |
143 |
if ui.configbool("perf", "stub"): |
|
144 |
return lambda x: 1 |
|
145 |
return len |
|
146 |
||
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
147 |
def gettimer(ui, opts=None): |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
148 |
"""return a timer function and formatter: (timer, formatter) |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
149 |
|
27303
57bd9c5431a5
perf: improve grammar of gettimer comment
timeless <timeless@mozdev.org>
parents:
27286
diff
changeset
|
150 |
This function exists to gather the creation of formatter in a single |
57bd9c5431a5
perf: improve grammar of gettimer comment
timeless <timeless@mozdev.org>
parents:
27286
diff
changeset
|
151 |
place instead of duplicating it in all performance commands.""" |
23788
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
152 |
|
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
153 |
# enforce an idle period before execution to counteract power management |
25850
b130764e3eb5
perf: mark experimental option presleep
Matt Mackall <mpm@selenic.com>
parents:
25494
diff
changeset
|
154 |
# experimental config: perf.presleep |
30149
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
155 |
time.sleep(getint(ui, "perf", "presleep", 1)) |
23788
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
156 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
157 |
if opts is None: |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
158 |
opts = {} |
30405
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
159 |
# redirect all to stderr unless buffer api is in use |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
160 |
if not ui._buffers: |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
161 |
ui = ui.copy() |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
162 |
uifout = safeattrsetter(ui, 'fout', ignoremissing=True) |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
163 |
if uifout: |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
164 |
# for "historical portability": |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
165 |
# ui.fout/ferr have been available since 1.9 (or 4e1ccd4c2b6d) |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30370
diff
changeset
|
166 |
uifout.set(ui.ferr) |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
167 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
168 |
# get a formatter |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
169 |
uiformatter = getattr(ui, 'formatter', None) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
170 |
if uiformatter: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
171 |
fm = uiformatter('perf', opts) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
172 |
else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
173 |
# for "historical portability": |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
174 |
# define formatter locally, because ui.formatter has been |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
175 |
# available since 2.2 (or ae5f92e154d3) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
176 |
from mercurial import node |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
177 |
class defaultformatter(object): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
178 |
"""Minimized composition of baseformatter and plainformatter |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
179 |
""" |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
180 |
def __init__(self, ui, topic, opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
181 |
self._ui = ui |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
182 |
if ui.debugflag: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
183 |
self.hexfunc = node.hex |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
184 |
else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
185 |
self.hexfunc = node.short |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
186 |
def __nonzero__(self): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
187 |
return False |
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31397
diff
changeset
|
188 |
__bool__ = __nonzero__ |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
189 |
def startitem(self): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
190 |
pass |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
191 |
def data(self, **data): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
192 |
pass |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
193 |
def write(self, fields, deftext, *fielddata, **opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
194 |
self._ui.write(deftext % fielddata, **opts) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
195 |
def condwrite(self, cond, fields, deftext, *fielddata, **opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
196 |
if cond: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
197 |
self._ui.write(deftext % fielddata, **opts) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
198 |
def plain(self, text, **opts): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
199 |
self._ui.write(text, **opts) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
200 |
def end(self): |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
201 |
pass |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
202 |
fm = defaultformatter(ui, 'perf', opts) |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
203 |
|
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
204 |
# stub function, runs code only once instead of in a loop |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
205 |
# experimental config: perf.stub |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
206 |
if ui.configbool("perf", "stub"): |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
207 |
return functools.partial(stub_timer, fm), fm |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
208 |
return functools.partial(_timer, fm), fm |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
209 |
|
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
210 |
def stub_timer(fm, func, title=None): |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
211 |
func() |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
212 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
213 |
def _timer(fm, func, title=None): |
31397
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30977
diff
changeset
|
214 |
gc.collect() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
215 |
results = [] |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30882
diff
changeset
|
216 |
begin = util.timer() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
217 |
count = 0 |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14322
diff
changeset
|
218 |
while True: |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
219 |
ostart = os.times() |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30882
diff
changeset
|
220 |
cstart = util.timer() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
221 |
r = func() |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30882
diff
changeset
|
222 |
cstop = util.timer() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
223 |
ostop = os.times() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
224 |
count += 1 |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
225 |
a, b = ostart, ostop |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
226 |
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
|
227 |
if cstop - begin > 3 and count >= 100: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
228 |
break |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
229 |
if cstop - begin > 10 and count >= 3: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
230 |
break |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
231 |
|
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
232 |
fm.startitem() |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
233 |
|
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
234 |
if title: |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
235 |
fm.write('title', '! %s\n', title) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
236 |
if r: |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
237 |
fm.write('result', '! result: %s\n', r) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
238 |
m = min(results) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
239 |
fm.plain('!') |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
240 |
fm.write('wall', ' wall %f', m[0]) |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
241 |
fm.write('comb', ' comb %f', m[1] + m[2]) |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
242 |
fm.write('user', ' user %f', m[1]) |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
243 |
fm.write('sys', ' sys %f', m[2]) |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
244 |
fm.write('count', ' (best of %d)', count) |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
245 |
fm.plain('\n') |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
246 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
247 |
# utilities for historical portability |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
248 |
|
30149
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
249 |
def getint(ui, section, name, default): |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
250 |
# for "historical portability": |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
251 |
# ui.configint has been available since 1.9 (or fa2b596db182) |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
252 |
v = ui.config(section, name, None) |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
253 |
if v is None: |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
254 |
return default |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
255 |
try: |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
256 |
return int(v) |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
257 |
except ValueError: |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
258 |
raise error.ConfigError(("%s.%s is not an integer ('%s')") |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
259 |
% (section, name, v)) |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
260 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
261 |
def safeattrsetter(obj, name, ignoremissing=False): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
262 |
"""Ensure that 'obj' has 'name' attribute before subsequent setattr |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
263 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
264 |
This function is aborted, if 'obj' doesn't have 'name' attribute |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
265 |
at runtime. This avoids overlooking removal of an attribute, which |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
266 |
breaks assumption of performance measurement, in the future. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
267 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
268 |
This function returns the object to (1) assign a new value, and |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
269 |
(2) restore an original value to the attribute. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
270 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
271 |
If 'ignoremissing' is true, missing 'name' attribute doesn't cause |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
272 |
abortion, and this function returns None. This is useful to |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
273 |
examine an attribute, which isn't ensured in all Mercurial |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
274 |
versions. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
275 |
""" |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
276 |
if not util.safehasattr(obj, name): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
277 |
if ignoremissing: |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
278 |
return None |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
279 |
raise error.Abort(("missing attribute %s of %s might break assumption" |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
280 |
" of performance measurement") % (name, obj)) |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
281 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
282 |
origvalue = getattr(obj, name) |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
283 |
class attrutil(object): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
284 |
def set(self, newvalue): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
285 |
setattr(obj, name, newvalue) |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
286 |
def restore(self): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
287 |
setattr(obj, name, origvalue) |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
288 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
289 |
return attrutil() |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
290 |
|
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
291 |
# utilities to examine each internal API changes |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
292 |
|
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
293 |
def getbranchmapsubsettable(): |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
294 |
# for "historical portability": |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
295 |
# subsettable is defined in: |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
296 |
# - branchmap since 2.9 (or 175c6fd8cacc) |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
297 |
# - repoview since 2.5 (or 59a9f18d4587) |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
298 |
for mod in (branchmap, repoview): |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
299 |
subsettable = getattr(mod, 'subsettable', None) |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
300 |
if subsettable: |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
301 |
return subsettable |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
302 |
|
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
303 |
# bisecting in bcee63733aad::59a9f18d4587 can reach here (both |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
304 |
# branchmap and repoview modules exist, but subsettable attribute |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
305 |
# doesn't) |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
306 |
raise error.Abort(("perfbranchmap not available with this Mercurial"), |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
307 |
hint="use 2.5 or later") |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
308 |
|
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
309 |
def getsvfs(repo): |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
310 |
"""Return appropriate object to access files under .hg/store |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
311 |
""" |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
312 |
# for "historical portability": |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
313 |
# repo.svfs has been available since 2.3 (or 7034365089bf) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
314 |
svfs = getattr(repo, 'svfs', None) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
315 |
if svfs: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
316 |
return svfs |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
317 |
else: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
318 |
return getattr(repo, 'sopener') |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
319 |
|
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
320 |
def getvfs(repo): |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
321 |
"""Return appropriate object to access files under .hg |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
322 |
""" |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
323 |
# for "historical portability": |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
324 |
# repo.vfs has been available since 2.3 (or 7034365089bf) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
325 |
vfs = getattr(repo, 'vfs', None) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
326 |
if vfs: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
327 |
return vfs |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
328 |
else: |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
329 |
return getattr(repo, 'opener') |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
330 |
|
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
331 |
def repocleartagscachefunc(repo): |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
332 |
"""Return the function to clear tags cache according to repo internal API |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
333 |
""" |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
334 |
if util.safehasattr(repo, '_tagscache'): # since 2.0 (or 9dca7653b525) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
335 |
# in this case, setattr(repo, '_tagscache', None) or so isn't |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
336 |
# correct way to clear tags cache, because existing code paths |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
337 |
# expect _tagscache to be a structured object. |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
338 |
def clearcache(): |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
339 |
# _tagscache has been filteredpropertycache since 2.5 (or |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
340 |
# 98c867ac1330), and delattr() can't work in such case |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
341 |
if '_tagscache' in vars(repo): |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
342 |
del repo.__dict__['_tagscache'] |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
343 |
return clearcache |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
344 |
|
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
345 |
repotags = safeattrsetter(repo, '_tags', ignoremissing=True) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
346 |
if repotags: # since 1.4 (or 5614a628d173) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
347 |
return lambda : repotags.set(None) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
348 |
|
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
349 |
repotagscache = safeattrsetter(repo, 'tagscache', ignoremissing=True) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
350 |
if repotagscache: # since 0.6 (or d7df759d0e97) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
351 |
return lambda : repotagscache.set(None) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
352 |
|
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
353 |
# Mercurial earlier than 0.6 (or d7df759d0e97) logically reaches |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
354 |
# this point, but it isn't so problematic, because: |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
355 |
# - repo.tags of such Mercurial isn't "callable", and repo.tags() |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
356 |
# in perftags() causes failure soon |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
357 |
# - perf.py itself has been available since 1.1 (or eb240755386d) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
358 |
raise error.Abort(("tags API of this hg command is unknown")) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
359 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
360 |
# perf commands |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
361 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
362 |
@command('perfwalk', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
363 |
def perfwalk(ui, repo, *pats, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
364 |
timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
365 |
try: |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14494
diff
changeset
|
366 |
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
|
367 |
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
|
368 |
except Exception: |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
369 |
try: |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14494
diff
changeset
|
370 |
m = scmutil.match(repo[None], pats, {}) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10176
diff
changeset
|
371 |
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
|
372 |
except Exception: |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
373 |
timer(lambda: len(list(cmdutil.walk(repo, pats, {})))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
374 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
375 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
376 |
@command('perfannotate', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
377 |
def perfannotate(ui, repo, f, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
378 |
timer, fm = gettimer(ui, opts) |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
379 |
fc = repo['.'][f] |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
380 |
timer(lambda: len(fc.annotate(True))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
381 |
fm.end() |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
382 |
|
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
383 |
@command('perfstatus', |
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
384 |
[('u', 'unknown', False, |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
385 |
'ask status to look for unknown files')] + formatteropts) |
18033
00ac420f24ee
perf: add option to perfstatus to get the status of unknown files
Siddharth Agarwal <sid0@fb.com>
parents:
17780
diff
changeset
|
386 |
def perfstatus(ui, repo, **opts): |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
387 |
#m = match.always(repo.root, repo.getcwd()) |
16683 | 388 |
#timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, |
389 |
# False)))) |
|
27017
cdc3e437b481
perf: un-bitrot perfstatus
Matt Mackall <mpm@selenic.com>
parents:
26748
diff
changeset
|
390 |
timer, fm = gettimer(ui, opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
391 |
timer(lambda: sum(map(len, repo.status(unknown=opts['unknown'])))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
392 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
393 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
394 |
@command('perfaddremove', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
395 |
def perfaddremove(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
396 |
timer, fm = gettimer(ui, opts) |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
397 |
try: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
398 |
oldquiet = repo.ui.quiet |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
399 |
repo.ui.quiet = True |
23533
891aaa7c0c70
scmutil: pass a matcher to scmutil.addremove() instead of a list of patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
23485
diff
changeset
|
400 |
matcher = scmutil.match(repo[None]) |
23537
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23533
diff
changeset
|
401 |
timer(lambda: scmutil.addremove(repo, matcher, "", dry_run=True)) |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
402 |
finally: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
403 |
repo.ui.quiet = oldquiet |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
404 |
fm.end() |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
405 |
|
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
406 |
def clearcaches(cl): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
407 |
# 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
|
408 |
if util.safehasattr(cl, 'clearcaches'): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
409 |
cl.clearcaches() |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
410 |
elif util.safehasattr(cl, '_nodecache'): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
411 |
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
|
412 |
cl._nodecache = {nullid: nullrev} |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
413 |
cl._nodepos = None |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
414 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
415 |
@command('perfheads', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
416 |
def perfheads(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
417 |
timer, fm = gettimer(ui, opts) |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
418 |
cl = repo.changelog |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
419 |
def d(): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
420 |
len(cl.headrevs()) |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
421 |
clearcaches(cl) |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
422 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
423 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
424 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
425 |
@command('perftags', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
426 |
def perftags(ui, repo, **opts): |
19786
fe8795dee77d
perf: rearrange imports of changelong and manifest to appease check-code
Augie Fackler <raf@durin42.com>
parents:
19712
diff
changeset
|
427 |
import mercurial.changelog |
fe8795dee77d
perf: rearrange imports of changelong and manifest to appease check-code
Augie Fackler <raf@durin42.com>
parents:
19712
diff
changeset
|
428 |
import mercurial.manifest |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
429 |
timer, fm = gettimer(ui, opts) |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
430 |
svfs = getsvfs(repo) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
431 |
repocleartagscache = repocleartagscachefunc(repo) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
432 |
def t(): |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
433 |
repo.changelog = mercurial.changelog.changelog(svfs) |
30219
3c8811efdddc
manifest: make manifestlog a storecache
Durham Goode <durham@fb.com>
parents:
30150
diff
changeset
|
434 |
repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
435 |
repocleartagscache() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
436 |
return len(repo.tags()) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
437 |
timer(t) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
438 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
439 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
440 |
@command('perfancestors', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
441 |
def perfancestors(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
442 |
timer, fm = gettimer(ui, opts) |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
443 |
heads = repo.changelog.headrevs() |
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
444 |
def d(): |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16858
diff
changeset
|
445 |
for a in repo.changelog.ancestors(heads): |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
446 |
pass |
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
447 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
448 |
fm.end() |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
449 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
450 |
@command('perfancestorset', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
451 |
def perfancestorset(ui, repo, revset, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
452 |
timer, fm = gettimer(ui, opts) |
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
453 |
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
|
454 |
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
|
455 |
def d(): |
18091
f7f8159caad3
ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents:
18080
diff
changeset
|
456 |
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
|
457 |
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
|
458 |
rev in s |
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
459 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
460 |
fm.end() |
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
461 |
|
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
462 |
@command('perfchangegroupchangelog', formatteropts + |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
463 |
[('', 'version', '02', 'changegroup version'), |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
464 |
('r', 'rev', '', 'revisions to add to changegroup')]) |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
465 |
def perfchangegroupchangelog(ui, repo, version='02', rev=None, **opts): |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
466 |
"""Benchmark producing a changelog group for a changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
467 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
468 |
This measures the time spent processing the changelog during a |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
469 |
bundle operation. This occurs during `hg bundle` and on a server |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
470 |
processing a `getbundle` wire protocol request (handles clones |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
471 |
and pull requests). |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
472 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
473 |
By default, all revisions are added to the changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
474 |
""" |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
475 |
cl = repo.changelog |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
476 |
revs = [cl.lookup(r) for r in repo.revs(rev or 'all()')] |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
477 |
bundler = changegroup.getbundler(version, repo) |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
478 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
479 |
def lookup(node): |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
480 |
# The real bundler reads the revision in order to access the |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
481 |
# manifest node and files list. Do that here. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
482 |
cl.read(node) |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
483 |
return node |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
484 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
485 |
def d(): |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
486 |
for chunk in bundler.group(revs, cl, lookup): |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
487 |
pass |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
488 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
489 |
timer, fm = gettimer(ui, opts) |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
490 |
timer(d) |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
491 |
fm.end() |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
492 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
493 |
@command('perfdirs', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
494 |
def perfdirs(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
495 |
timer, fm = gettimer(ui, opts) |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
496 |
dirstate = repo.dirstate |
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
497 |
'a' in dirstate |
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
498 |
def d(): |
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
499 |
dirstate.dirs() |
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
500 |
del dirstate._dirs |
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
501 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
502 |
fm.end() |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
503 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
504 |
@command('perfdirstate', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
505 |
def perfdirstate(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
506 |
timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
507 |
"a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
508 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
509 |
repo.dirstate.invalidate() |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
510 |
"a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
511 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
512 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
513 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
514 |
@command('perfdirstatedirs', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
515 |
def perfdirstatedirs(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
516 |
timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
517 |
"a" in repo.dirstate |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
518 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
519 |
"a" in repo.dirstate._dirs |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
520 |
del repo.dirstate._dirs |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
521 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
522 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
523 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
524 |
@command('perfdirstatefoldmap', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
525 |
def perfdirstatefoldmap(ui, repo, **opts): |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
526 |
timer, fm = gettimer(ui, opts) |
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
527 |
dirstate = repo.dirstate |
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
528 |
'a' in dirstate |
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
529 |
def d(): |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
530 |
dirstate._filefoldmap.get('a') |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
531 |
del dirstate._filefoldmap |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
532 |
timer(d) |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
533 |
fm.end() |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
534 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
535 |
@command('perfdirfoldmap', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
536 |
def perfdirfoldmap(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
537 |
timer, fm = gettimer(ui, opts) |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
538 |
dirstate = repo.dirstate |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
539 |
'a' in dirstate |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
540 |
def d(): |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
541 |
dirstate._dirfoldmap.get('a') |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
542 |
del dirstate._dirfoldmap |
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
543 |
del dirstate._dirs |
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
544 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
545 |
fm.end() |
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
546 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
547 |
@command('perfdirstatewrite', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
548 |
def perfdirstatewrite(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
549 |
timer, fm = gettimer(ui, opts) |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
550 |
ds = repo.dirstate |
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
551 |
"a" in ds |
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
552 |
def d(): |
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
553 |
ds._dirty = True |
26748
5ba0a99ff27f
dirstate: make dirstate.write() callers pass transaction object to it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25850
diff
changeset
|
554 |
ds.write(repo.currenttransaction()) |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
555 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
556 |
fm.end() |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
557 |
|
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
558 |
@command('perfmergecalculate', |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
559 |
[('r', 'rev', '.', 'rev to merge against')] + formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
560 |
def perfmergecalculate(ui, repo, rev, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
561 |
timer, fm = gettimer(ui, opts) |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
562 |
wctx = repo[None] |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
563 |
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
|
564 |
ancestor = wctx.ancestor(rctx) |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
565 |
# 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
|
566 |
# that cache |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
567 |
wctx.dirty() |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
568 |
def d(): |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
569 |
# 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
|
570 |
# our benchmark |
27098
64cb281d23a5
contrib/perf: fix perfmergecalculate
timeless <timeless@mozdev.org>
parents:
27097
diff
changeset
|
571 |
merge.calculateupdates(repo, wctx, rctx, [ancestor], False, False, |
27345
98266b1d144d
merge: restate calculateupdates in terms of a matcher
Augie Fackler <augie@google.com>
parents:
27308
diff
changeset
|
572 |
acceptremote=True, followcopies=True) |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
573 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
574 |
fm.end() |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
575 |
|
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
576 |
@command('perfpathcopies', [], "REV REV") |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
577 |
def perfpathcopies(ui, repo, rev1, rev2, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
578 |
timer, fm = gettimer(ui, opts) |
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
579 |
ctx1 = scmutil.revsingle(repo, rev1, rev1) |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
580 |
ctx2 = scmutil.revsingle(repo, rev2, rev2) |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
581 |
def d(): |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
582 |
copies.pathcopies(ctx1, ctx2) |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
583 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
584 |
fm.end() |
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
585 |
|
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
586 |
@command('perfphases', [], "") |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
587 |
def perfphases(ui, repo, **opts): |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
588 |
"""benchmark phasesets computation""" |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
589 |
timer, fm = gettimer(ui, opts) |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
590 |
phases = repo._phasecache |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
591 |
def d(): |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
592 |
phases.invalidate() |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
593 |
phases.loadphaserevs(repo) |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
594 |
timer(d) |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
595 |
fm.end() |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
596 |
|
19712
79e5de2bfa8c
perfmanifest: allow and require passing in a rev
Siddharth Agarwal <sid0@fb.com>
parents:
19711
diff
changeset
|
597 |
@command('perfmanifest', [], 'REV') |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
598 |
def perfmanifest(ui, repo, rev, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
599 |
timer, fm = gettimer(ui, opts) |
19712
79e5de2bfa8c
perfmanifest: allow and require passing in a rev
Siddharth Agarwal <sid0@fb.com>
parents:
19711
diff
changeset
|
600 |
ctx = scmutil.revsingle(repo, rev, rev) |
79e5de2bfa8c
perfmanifest: allow and require passing in a rev
Siddharth Agarwal <sid0@fb.com>
parents:
19711
diff
changeset
|
601 |
t = ctx.manifestnode() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
602 |
def d(): |
30370
10c924596e5c
manifest: move clearcaches to manifestlog
Durham Goode <durham@fb.com>
parents:
30369
diff
changeset
|
603 |
repo.manifestlog.clearcaches() |
30369
d79c141fdf41
manifest: remove usages of manifest.read
Durham Goode <durham@fb.com>
parents:
30337
diff
changeset
|
604 |
repo.manifestlog[t].read() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
605 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
606 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
607 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
608 |
@command('perfchangeset', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
609 |
def perfchangeset(ui, repo, rev, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
610 |
timer, fm = gettimer(ui, opts) |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
611 |
n = repo[rev].node() |
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
612 |
def d(): |
19378
9de689d20230
cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents:
19322
diff
changeset
|
613 |
repo.changelog.read(n) |
16266
77d56a5e74a5
perf: add a changeset test
Matt Mackall <mpm@selenic.com>
parents:
16262
diff
changeset
|
614 |
#repo.changelog._cache = None |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
615 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
616 |
fm.end() |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
617 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
618 |
@command('perfindex', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
619 |
def perfindex(ui, repo, **opts): |
13255
2696730ca233
perf: make perfindex results useful on hg with lazyparser
Matt Mackall <mpm@selenic.com>
parents:
13254
diff
changeset
|
620 |
import mercurial.revlog |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
621 |
timer, fm = gettimer(ui, opts) |
13277
9f707b297b0f
perf: restore lazyindex hack
Matt Mackall <mpm@selenic.com>
parents:
13262
diff
changeset
|
622 |
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
|
623 |
n = repo["tip"].node() |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
624 |
svfs = getsvfs(repo) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
625 |
def d(): |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
626 |
cl = mercurial.revlog.revlog(svfs, "00changelog.i") |
16260
33fcad3cfbbc
perf: tweak tests for testing index performance improvements
Matt Mackall <mpm@selenic.com>
parents:
14671
diff
changeset
|
627 |
cl.rev(n) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
628 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
629 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
630 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
631 |
@command('perfstartup', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
632 |
def perfstartup(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
633 |
timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
634 |
cmd = sys.argv[0] |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
635 |
def d(): |
27382
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
636 |
if os.name != 'nt': |
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
637 |
os.system("HGRCPATH= %s version -q > /dev/null" % cmd) |
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
638 |
else: |
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
639 |
os.environ['HGRCPATH'] = '' |
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
640 |
os.system("%s version -q > NUL" % cmd) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
641 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
642 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
643 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
644 |
@command('perfparents', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
645 |
def perfparents(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
646 |
timer, fm = gettimer(ui, opts) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
647 |
# control the number of commits perfparents iterates over |
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
648 |
# experimental config: perf.parentscount |
30149
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30148
diff
changeset
|
649 |
count = getint(ui, "perf", "parentscount", 1000) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
650 |
if len(repo.changelog) < count: |
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
651 |
raise error.Abort("repo needs %d commits for this test" % count) |
27100
8d5dba93aa4f
contrib/perf: perfparents handle filtered repos
timeless <timeless@mozdev.org>
parents:
27099
diff
changeset
|
652 |
repo = repo.unfiltered() |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
653 |
nl = [repo.changelog.node(i) for i in xrange(count)] |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
654 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
655 |
for n in nl: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
656 |
repo.changelog.parents(n) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
657 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
658 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
659 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
660 |
@command('perfctxfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
661 |
def perfctxfiles(ui, repo, x, **opts): |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
662 |
x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
663 |
timer, fm = gettimer(ui, opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
664 |
def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
665 |
len(repo[x].files()) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
666 |
timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
667 |
fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
668 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
669 |
@command('perfrawfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
670 |
def perfrawfiles(ui, repo, x, **opts): |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
671 |
x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
672 |
timer, fm = gettimer(ui, opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
673 |
cl = repo.changelog |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
674 |
def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
675 |
len(cl.read(x)[3]) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
676 |
timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
677 |
fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
678 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
679 |
@command('perflookup', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
680 |
def perflookup(ui, repo, rev, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
681 |
timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
682 |
timer(lambda: len(repo.lookup(rev))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
683 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
684 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
685 |
@command('perfrevrange', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
686 |
def perfrevrange(ui, repo, *specs, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
687 |
timer, fm = gettimer(ui, opts) |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
688 |
revrange = scmutil.revrange |
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
689 |
timer(lambda: len(revrange(repo, specs))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
690 |
fm.end() |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
691 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
692 |
@command('perfnodelookup', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
693 |
def perfnodelookup(ui, repo, rev, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
694 |
timer, fm = gettimer(ui, opts) |
16309 | 695 |
import mercurial.revlog |
696 |
mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
|
697 |
n = repo[rev].node() |
|
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
698 |
cl = mercurial.revlog.revlog(getsvfs(repo), "00changelog.i") |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
699 |
def d(): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
700 |
cl.rev(n) |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
701 |
clearcaches(cl) |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
702 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
703 |
fm.end() |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
704 |
|
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
705 |
@command('perflog', |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
706 |
[('', 'rename', False, 'ask log to follow renames')] + formatteropts) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
707 |
def perflog(ui, repo, rev=None, **opts): |
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
708 |
if rev is None: |
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
709 |
rev=[] |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
710 |
timer, fm = gettimer(ui, opts) |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
711 |
ui.pushbuffer() |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
712 |
timer(lambda: commands.log(ui, repo, rev=rev, date='', user='', |
9932
2fcbef9a349a
perf.perflog: add option to follow renames
Alexander Solovyov <piranha@piranha.org.ua>
parents:
9826
diff
changeset
|
713 |
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
|
714 |
ui.popbuffer() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
715 |
fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
716 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
717 |
@command('perfmoonwalk', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
718 |
def perfmoonwalk(ui, repo, **opts): |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
719 |
"""benchmark walking the changelog backwards |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
720 |
|
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
721 |
This also loads the changelog data for each revision in the changelog. |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
722 |
""" |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
723 |
timer, fm = gettimer(ui, opts) |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
724 |
def moonwalk(): |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
725 |
for i in xrange(len(repo), -1, -1): |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
726 |
ctx = repo[i] |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
727 |
ctx.branch() # read changelog data (in addition to the index) |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
728 |
timer(moonwalk) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
729 |
fm.end() |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
730 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
731 |
@command('perftemplating', formatteropts) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
732 |
def perftemplating(ui, repo, rev=None, **opts): |
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
733 |
if rev is None: |
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
734 |
rev=[] |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
735 |
timer, fm = gettimer(ui, opts) |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
736 |
ui.pushbuffer() |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
737 |
timer(lambda: commands.log(ui, repo, rev=rev, date='', user='', |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
738 |
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
|
739 |
' {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
|
740 |
ui.popbuffer() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
741 |
fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
742 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
743 |
@command('perfcca', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
744 |
def perfcca(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
745 |
timer, fm = gettimer(ui, opts) |
17216
01c1ee4bd1dd
perf: fix perfcca to work with new casecollisionauditor interface
Joshua Redstone <joshua.redstone@fb.com>
parents:
16866
diff
changeset
|
746 |
timer(lambda: scmutil.casecollisionauditor(ui, False, repo.dirstate)) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
747 |
fm.end() |
16386
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
748 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
749 |
@command('perffncacheload', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
750 |
def perffncacheload(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
751 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
752 |
s = repo.store |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
753 |
def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
754 |
s.fncache._load() |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
755 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
756 |
fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
757 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
758 |
@command('perffncachewrite', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
759 |
def perffncachewrite(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
760 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
761 |
s = repo.store |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
762 |
s.fncache._load() |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
763 |
lock = repo.lock() |
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
764 |
tr = repo.transaction('perffncachewrite') |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
765 |
def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
766 |
s.fncache._dirty = True |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
767 |
s.fncache.write(tr) |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
768 |
timer(d) |
30069
98b9846a131e
perf: release lock after transaction in perffncachewrite
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30018
diff
changeset
|
769 |
tr.close() |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
770 |
lock.release() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
771 |
fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
772 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
773 |
@command('perffncacheencode', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
774 |
def perffncacheencode(ui, repo, **opts): |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
775 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
776 |
s = repo.store |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
777 |
s.fncache._load() |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
778 |
def d(): |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
779 |
for p in s.fncache.entries: |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
780 |
s.encode(p) |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
781 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
782 |
fm.end() |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
783 |
|
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
784 |
@command('perfbdiff', revlogopts + formatteropts + [ |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
785 |
('', 'count', 1, 'number of revisions to test (when using --startrev)'), |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
786 |
('', 'alldata', False, 'test bdiffs for all associated revisions')], |
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
787 |
'-c|-m|FILE REV') |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
788 |
def perfbdiff(ui, repo, file_, rev=None, count=None, **opts): |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
789 |
"""benchmark a bdiff between revisions |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
790 |
|
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
791 |
By default, benchmark a bdiff between its delta parent and itself. |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
792 |
|
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
793 |
With ``--count``, benchmark bdiffs between delta parents and self for N |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
794 |
revisions starting at the specified revision. |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
795 |
|
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
796 |
With ``--alldata``, assume the requested revision is a changeset and |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
797 |
measure bdiffs for all changes related to that changeset (manifest |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
798 |
and filelogs). |
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
799 |
""" |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
800 |
if opts['alldata']: |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
801 |
opts['changelog'] = True |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
802 |
|
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
803 |
if opts.get('changelog') or opts.get('manifest'): |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
804 |
file_, rev = None, file_ |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
805 |
elif rev is None: |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
806 |
raise error.CommandError('perfbdiff', 'invalid arguments') |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
807 |
|
30335
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30307
diff
changeset
|
808 |
textpairs = [] |
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30307
diff
changeset
|
809 |
|
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
810 |
r = cmdutil.openrevlog(repo, 'perfbdiff', file_, opts) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
811 |
|
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
812 |
startrev = r.rev(r.lookup(rev)) |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
813 |
for rev in range(startrev, min(startrev + count, len(r) - 1)): |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
814 |
if opts['alldata']: |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
815 |
# Load revisions associated with changeset. |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
816 |
ctx = repo[rev] |
30426
605e3b126d46
perf: unbust perfbdiff --alldata
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30405
diff
changeset
|
817 |
mtext = repo.manifestlog._revlog.revision(ctx.manifestnode()) |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
818 |
for pctx in ctx.parents(): |
30426
605e3b126d46
perf: unbust perfbdiff --alldata
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30405
diff
changeset
|
819 |
pman = repo.manifestlog._revlog.revision(pctx.manifestnode()) |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
820 |
textpairs.append((pman, mtext)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
821 |
|
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
822 |
# Load filelog revisions by iterating manifest delta. |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
823 |
man = ctx.manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
824 |
pman = ctx.p1().manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
825 |
for filename, change in pman.diff(man).items(): |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
826 |
fctx = repo.file(filename) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
827 |
f1 = fctx.revision(change[0][0] or -1) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
828 |
f2 = fctx.revision(change[1][0] or -1) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
829 |
textpairs.append((f1, f2)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
830 |
else: |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
831 |
dp = r.deltaparent(rev) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
832 |
textpairs.append((r.revision(dp), r.revision(rev))) |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
833 |
|
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
834 |
def d(): |
30335
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30307
diff
changeset
|
835 |
for pair in textpairs: |
32202
ded48ad55146
bdiff: proxy through mdiff module
Yuya Nishihara <yuya@tcha.org>
parents:
31823
diff
changeset
|
836 |
mdiff.textdiff(*pair) |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
837 |
|
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
838 |
timer, fm = gettimer(ui, opts) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
839 |
timer(d) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
840 |
fm.end() |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
841 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
842 |
@command('perfdiffwd', formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
843 |
def perfdiffwd(ui, repo, **opts): |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
844 |
"""Profile diff of working directory changes""" |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
845 |
timer, fm = gettimer(ui, opts) |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
846 |
options = { |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
847 |
'w': 'ignore_all_space', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
848 |
'b': 'ignore_space_change', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
849 |
'B': 'ignore_blank_lines', |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
850 |
} |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
851 |
|
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
852 |
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
|
853 |
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
|
854 |
def d(): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
855 |
ui.pushbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
856 |
commands.diff(ui, repo, **opts) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
857 |
ui.popbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
858 |
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
|
859 |
timer(d, title) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
860 |
fm.end() |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
861 |
|
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
862 |
@command('perfrevlogindex', revlogopts + formatteropts, |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
863 |
'-c|-m|FILE') |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
864 |
def perfrevlogindex(ui, repo, file_=None, **opts): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
865 |
"""Benchmark operations against a revlog index. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
866 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
867 |
This tests constructing a revlog instance, reading index data, |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
868 |
parsing index data, and performing various operations related to |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
869 |
index data. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
870 |
""" |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
871 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
872 |
rl = cmdutil.openrevlog(repo, 'perfrevlogindex', file_, opts) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
873 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
874 |
opener = getattr(rl, 'opener') # trick linter |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
875 |
indexfile = rl.indexfile |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
876 |
data = opener.read(indexfile) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
877 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
878 |
header = struct.unpack('>I', data[0:4])[0] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
879 |
version = header & 0xFFFF |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
880 |
if version == 1: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
881 |
revlogio = revlog.revlogio() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
882 |
inline = header & (1 << 16) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
883 |
else: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
884 |
raise error.Abort(('unsupported revlog version: %d') % version) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
885 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
886 |
rllen = len(rl) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
887 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
888 |
node0 = rl.node(0) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
889 |
node25 = rl.node(rllen // 4) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
890 |
node50 = rl.node(rllen // 2) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
891 |
node75 = rl.node(rllen // 4 * 3) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
892 |
node100 = rl.node(rllen - 1) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
893 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
894 |
allrevs = range(rllen) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
895 |
allrevsrev = list(reversed(allrevs)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
896 |
allnodes = [rl.node(rev) for rev in range(rllen)] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
897 |
allnodesrev = list(reversed(allnodes)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
898 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
899 |
def constructor(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
900 |
revlog.revlog(opener, indexfile) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
901 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
902 |
def read(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
903 |
with opener(indexfile) as fh: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
904 |
fh.read() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
905 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
906 |
def parseindex(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
907 |
revlogio.parseindex(data, inline) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
908 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
909 |
def getentry(revornode): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
910 |
index = revlogio.parseindex(data, inline)[0] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
911 |
index[revornode] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
912 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
913 |
def getentries(revs, count=1): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
914 |
index = revlogio.parseindex(data, inline)[0] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
915 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
916 |
for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
917 |
for rev in revs: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
918 |
index[rev] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
919 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
920 |
def resolvenode(node): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
921 |
nodemap = revlogio.parseindex(data, inline)[1] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
922 |
# This only works for the C code. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
923 |
if nodemap is None: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
924 |
return |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
925 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
926 |
try: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
927 |
nodemap[node] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
928 |
except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
929 |
pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
930 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
931 |
def resolvenodes(nodes, count=1): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
932 |
nodemap = revlogio.parseindex(data, inline)[1] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
933 |
if nodemap is None: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
934 |
return |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
935 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
936 |
for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
937 |
for node in nodes: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
938 |
try: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
939 |
nodemap[node] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
940 |
except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
941 |
pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
942 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
943 |
benches = [ |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
944 |
(constructor, 'revlog constructor'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
945 |
(read, 'read'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
946 |
(parseindex, 'create index object'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
947 |
(lambda: getentry(0), 'retrieve index entry for rev 0'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
948 |
(lambda: resolvenode('a' * 20), 'look up missing node'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
949 |
(lambda: resolvenode(node0), 'look up node at rev 0'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
950 |
(lambda: resolvenode(node25), 'look up node at 1/4 len'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
951 |
(lambda: resolvenode(node50), 'look up node at 1/2 len'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
952 |
(lambda: resolvenode(node75), 'look up node at 3/4 len'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
953 |
(lambda: resolvenode(node100), 'look up node at tip'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
954 |
# 2x variation is to measure caching impact. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
955 |
(lambda: resolvenodes(allnodes), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
956 |
'look up all nodes (forward)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
957 |
(lambda: resolvenodes(allnodes, 2), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
958 |
'look up all nodes 2x (forward)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
959 |
(lambda: resolvenodes(allnodesrev), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
960 |
'look up all nodes (reverse)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
961 |
(lambda: resolvenodes(allnodesrev, 2), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
962 |
'look up all nodes 2x (reverse)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
963 |
(lambda: getentries(allrevs), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
964 |
'retrieve all index entries (forward)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
965 |
(lambda: getentries(allrevs, 2), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
966 |
'retrieve all index entries 2x (forward)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
967 |
(lambda: getentries(allrevsrev), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
968 |
'retrieve all index entries (reverse)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
969 |
(lambda: getentries(allrevsrev, 2), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
970 |
'retrieve all index entries 2x (reverse)'), |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
971 |
] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
972 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
973 |
for fn, title in benches: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
974 |
timer, fm = gettimer(ui, opts) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
975 |
timer(fn, title=title) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
976 |
fm.end() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
977 |
|
32531
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32467
diff
changeset
|
978 |
@command('perfrevlogrevisions', revlogopts + formatteropts + |
27493
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
979 |
[('d', 'dist', 100, 'distance between the revisions'), |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
980 |
('s', 'startrev', 0, 'revision to start reading at'), |
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
981 |
('', 'reverse', False, 'read in reverse')], |
27492
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
982 |
'-c|-m|FILE') |
32531
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32467
diff
changeset
|
983 |
def perfrevlogrevisions(ui, repo, file_=None, startrev=0, reverse=False, |
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32467
diff
changeset
|
984 |
**opts): |
27492
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
985 |
"""Benchmark reading a series of revisions from a revlog. |
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
986 |
|
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
987 |
By default, we read every ``-d/--dist`` revision from 0 to tip of |
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
988 |
the specified revlog. |
27493
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
989 |
|
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
990 |
The start revision can be defined via ``-s/--startrev``. |
27492
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
991 |
""" |
32531
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32467
diff
changeset
|
992 |
rl = cmdutil.openrevlog(repo, 'perfrevlogrevisions', file_, opts) |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
993 |
rllen = getlen(ui)(rl) |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
994 |
|
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
995 |
def d(): |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
996 |
rl.clearcaches() |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
997 |
|
32224
6b582f9b6e5e
perf: don't clobber startrev variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32202
diff
changeset
|
998 |
beginrev = startrev |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
999 |
endrev = rllen |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
1000 |
dist = opts['dist'] |
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
1001 |
|
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
1002 |
if reverse: |
32224
6b582f9b6e5e
perf: don't clobber startrev variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32202
diff
changeset
|
1003 |
beginrev, endrev = endrev, beginrev |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
1004 |
dist = -1 * dist |
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
1005 |
|
32224
6b582f9b6e5e
perf: don't clobber startrev variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32202
diff
changeset
|
1006 |
for x in xrange(beginrev, endrev, dist): |
32297
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32232
diff
changeset
|
1007 |
# Old revisions don't support passing int. |
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32232
diff
changeset
|
1008 |
n = rl.node(x) |
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32232
diff
changeset
|
1009 |
rl.revision(n) |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
1010 |
|
32225
c68c400d0a2d
perf: move gettimer() call
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32224
diff
changeset
|
1011 |
timer, fm = gettimer(ui, opts) |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
1012 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1013 |
fm.end() |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
1014 |
|
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1015 |
@command('perfrevlogchunks', revlogopts + formatteropts + |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1016 |
[('e', 'engines', '', 'compression engines to use'), |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1017 |
('s', 'startrev', 0, 'revision to start at')], |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1018 |
'-c|-m|FILE') |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1019 |
def perfrevlogchunks(ui, repo, file_=None, engines=None, startrev=0, **opts): |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1020 |
"""Benchmark operations on revlog chunks. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1021 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1022 |
Logically, each revlog is a collection of fulltext revisions. However, |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1023 |
stored within each revlog are "chunks" of possibly compressed data. This |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1024 |
data needs to be read and decompressed or compressed and written. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1025 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1026 |
This command measures the time it takes to read+decompress and recompress |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1027 |
chunks in a revlog. It effectively isolates I/O and compression performance. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1028 |
For measurements of higher-level operations like resolving revisions, |
32531
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32467
diff
changeset
|
1029 |
see ``perfrevlogrevisions`` and ``perfrevlogrevision``. |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1030 |
""" |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1031 |
rl = cmdutil.openrevlog(repo, 'perfrevlogchunks', file_, opts) |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1032 |
|
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1033 |
# _chunkraw was renamed to _getsegmentforrevs. |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1034 |
try: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1035 |
segmentforrevs = rl._getsegmentforrevs |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1036 |
except AttributeError: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1037 |
segmentforrevs = rl._chunkraw |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1038 |
|
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1039 |
# Verify engines argument. |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1040 |
if engines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1041 |
engines = set(e.strip() for e in engines.split(',')) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1042 |
for engine in engines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1043 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1044 |
util.compressionengines[engine] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1045 |
except KeyError: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1046 |
raise error.Abort('unknown compression engine: %s' % engine) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1047 |
else: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1048 |
engines = [] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1049 |
for e in util.compengines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1050 |
engine = util.compengines[e] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1051 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1052 |
if engine.available(): |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1053 |
engine.revlogcompressor().compress('dummy') |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1054 |
engines.append(e) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1055 |
except NotImplementedError: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1056 |
pass |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1057 |
|
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1058 |
revs = list(rl.revs(startrev, len(rl) - 1)) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1059 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1060 |
def rlfh(rl): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1061 |
if rl._inline: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1062 |
return getsvfs(repo)(rl.indexfile) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1063 |
else: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1064 |
return getsvfs(repo)(rl.datafile) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1065 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1066 |
def doread(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1067 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1068 |
for rev in revs: |
32228
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32225
diff
changeset
|
1069 |
segmentforrevs(rev, rev) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1070 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1071 |
def doreadcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1072 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1073 |
fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1074 |
for rev in revs: |
32228
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32225
diff
changeset
|
1075 |
segmentforrevs(rev, rev, df=fh) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1076 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1077 |
def doreadbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1078 |
rl.clearcaches() |
32228
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32225
diff
changeset
|
1079 |
segmentforrevs(revs[0], revs[-1]) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1080 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1081 |
def doreadbatchcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1082 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1083 |
fh = rlfh(rl) |
32228
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32225
diff
changeset
|
1084 |
segmentforrevs(revs[0], revs[-1], df=fh) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1085 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1086 |
def dochunk(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1087 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1088 |
fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1089 |
for rev in revs: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1090 |
rl._chunk(rev, df=fh) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1091 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1092 |
chunks = [None] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1093 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1094 |
def dochunkbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1095 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1096 |
fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1097 |
# Save chunks as a side-effect. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1098 |
chunks[0] = rl._chunks(revs, df=fh) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1099 |
|
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1100 |
def docompress(compressor): |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1101 |
rl.clearcaches() |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1102 |
|
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1103 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1104 |
# Swap in the requested compression engine. |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1105 |
oldcompressor = rl._compressor |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1106 |
rl._compressor = compressor |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1107 |
for chunk in chunks[0]: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1108 |
rl.compress(chunk) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1109 |
finally: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1110 |
rl._compressor = oldcompressor |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1111 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1112 |
benches = [ |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1113 |
(lambda: doread(), 'read'), |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1114 |
(lambda: doreadcachedfh(), 'read w/ reused fd'), |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1115 |
(lambda: doreadbatch(), 'read batch'), |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1116 |
(lambda: doreadbatchcachedfh(), 'read batch w/ reused fd'), |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1117 |
(lambda: dochunk(), 'chunk'), |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1118 |
(lambda: dochunkbatch(), 'chunk batch'), |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1119 |
] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1120 |
|
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1121 |
for engine in sorted(engines): |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1122 |
compressor = util.compengines[engine].revlogcompressor() |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1123 |
benches.append((functools.partial(docompress, compressor), |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1124 |
'compress w/ %s' % engine)) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
1125 |
|
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1126 |
for fn, title in benches: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1127 |
timer, fm = gettimer(ui, opts) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1128 |
timer(fn, title=title) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1129 |
fm.end() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
1130 |
|
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1131 |
@command('perfrevlogrevision', revlogopts + formatteropts + |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1132 |
[('', 'cache', False, 'use caches instead of clearing')], |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1133 |
'-c|-m|FILE REV') |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1134 |
def perfrevlogrevision(ui, repo, file_, rev=None, cache=None, **opts): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1135 |
"""Benchmark obtaining a revlog revision. |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1136 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1137 |
Obtaining a revlog revision consists of roughly the following steps: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1138 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1139 |
1. Compute the delta chain |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1140 |
2. Obtain the raw chunks for that delta chain |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1141 |
3. Decompress each raw chunk |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1142 |
4. Apply binary patches to obtain fulltext |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1143 |
5. Verify hash of fulltext |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1144 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1145 |
This command measures the time spent in each of these phases. |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1146 |
""" |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1147 |
if opts.get('changelog') or opts.get('manifest'): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1148 |
file_, rev = None, file_ |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1149 |
elif rev is None: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1150 |
raise error.CommandError('perfrevlogrevision', 'invalid arguments') |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1151 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1152 |
r = cmdutil.openrevlog(repo, 'perfrevlogrevision', file_, opts) |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1153 |
|
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1154 |
# _chunkraw was renamed to _getsegmentforrevs. |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1155 |
try: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1156 |
segmentforrevs = r._getsegmentforrevs |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1157 |
except AttributeError: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1158 |
segmentforrevs = r._chunkraw |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
1159 |
|
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1160 |
node = r.lookup(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1161 |
rev = r.rev(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1162 |
|
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1163 |
def getrawchunks(data, chain): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1164 |
start = r.start |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1165 |
length = r.length |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1166 |
inline = r._inline |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1167 |
iosize = r._io.size |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1168 |
buffer = util.buffer |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1169 |
offset = start(chain[0]) |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1170 |
|
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1171 |
chunks = [] |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1172 |
ladd = chunks.append |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1173 |
|
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1174 |
for rev in chain: |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1175 |
chunkstart = start(rev) |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1176 |
if inline: |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1177 |
chunkstart += (rev + 1) * iosize |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1178 |
chunklength = length(rev) |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1179 |
ladd(buffer(data, chunkstart - offset, chunklength)) |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1180 |
|
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1181 |
return chunks |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1182 |
|
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1183 |
def dodeltachain(rev): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1184 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1185 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1186 |
r._deltachain(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1187 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1188 |
def doread(chain): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1189 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1190 |
r.clearcaches() |
32228
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32225
diff
changeset
|
1191 |
segmentforrevs(chain[0], chain[-1]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1192 |
|
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1193 |
def dorawchunks(data, chain): |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1194 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1195 |
r.clearcaches() |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1196 |
getrawchunks(data, chain) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1197 |
|
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1198 |
def dodecompress(chunks): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1199 |
decomp = r.decompress |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1200 |
for chunk in chunks: |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1201 |
decomp(chunk) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1202 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1203 |
def dopatch(text, bins): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1204 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1205 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1206 |
mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1207 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1208 |
def dohash(text): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1209 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1210 |
r.clearcaches() |
30584
be5b2098a817
revlog: merge hash checking subfunctions
Remi Chaintron <remi@fb.com>
parents:
30451
diff
changeset
|
1211 |
r.checkhash(text, node, rev=rev) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1212 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1213 |
def dorevision(): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1214 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1215 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1216 |
r.revision(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1217 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1218 |
chain = r._deltachain(rev)[0] |
32228
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32225
diff
changeset
|
1219 |
data = segmentforrevs(chain[0], chain[-1])[1] |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1220 |
rawchunks = getrawchunks(data, chain) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1221 |
bins = r._chunks(chain) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1222 |
text = str(bins[0]) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1223 |
bins = bins[1:] |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1224 |
text = mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1225 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1226 |
benches = [ |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1227 |
(lambda: dorevision(), 'full'), |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1228 |
(lambda: dodeltachain(rev), 'deltachain'), |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1229 |
(lambda: doread(chain), 'read'), |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1230 |
(lambda: dorawchunks(data, chain), 'rawchunks'), |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
1231 |
(lambda: dodecompress(rawchunks), 'decompress'), |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1232 |
(lambda: dopatch(text, bins), 'patch'), |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1233 |
(lambda: dohash(text), 'hash'), |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1234 |
] |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1235 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1236 |
for fn, title in benches: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1237 |
timer, fm = gettimer(ui, opts) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1238 |
timer(fn, title=title) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1239 |
fm.end() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
1240 |
|
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
1241 |
@command('perfrevset', |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
1242 |
[('C', 'clear', False, 'clear volatile cache between each call.'), |
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
1243 |
('', 'contexts', False, 'obtain changectx for each revision')] |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1244 |
+ formatteropts, "REVSET") |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
1245 |
def perfrevset(ui, repo, expr, clear=False, contexts=False, **opts): |
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
1246 |
"""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
|
1247 |
|
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18304
diff
changeset
|
1248 |
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
|
1249 |
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
|
1250 |
and obsolete related cache.""" |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1251 |
timer, fm = gettimer(ui, opts) |
18062
1471f5e83686
perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents:
18033
diff
changeset
|
1252 |
def d(): |
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
1253 |
if clear: |
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
1254 |
repo.invalidatevolatilesets() |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
1255 |
if contexts: |
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
1256 |
for ctx in repo.set(expr): pass |
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
1257 |
else: |
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
1258 |
for r in repo.revs(expr): pass |
18062
1471f5e83686
perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents:
18033
diff
changeset
|
1259 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1260 |
fm.end() |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1261 |
|
32390
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1262 |
def _clearobsstore(repo): |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1263 |
unfi = repo.unfiltered() |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1264 |
if 'obsstore' in vars(unfi): |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1265 |
del unfi.obsstore |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1266 |
del unfi._filecache['obsstore'] |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1267 |
|
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1268 |
@command('perfvolatilesets', |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1269 |
[('', 'clear-obsstore', False, 'drop obsstore between each call.'), |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1270 |
] + formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1271 |
def perfvolatilesets(ui, repo, *names, **opts): |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1272 |
"""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
|
1273 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1274 |
Volatile set computes element related to filtering and obsolescence.""" |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1275 |
timer, fm = gettimer(ui, opts) |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1276 |
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
|
1277 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1278 |
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
|
1279 |
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
|
1280 |
repo.invalidatevolatilesets() |
32390
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1281 |
if opts['clear_obsstore']: |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1282 |
_clearobsstore(repo) |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1283 |
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
|
1284 |
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
|
1285 |
|
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
1286 |
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
|
1287 |
if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
1288 |
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
|
1289 |
|
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
1290 |
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
|
1291 |
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
|
1292 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1293 |
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
|
1294 |
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
|
1295 |
repo.invalidatevolatilesets() |
32390
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1296 |
if opts['clear_obsstore']: |
f90419a90cc3
perf: allow to clear the obsstore in 'perfvolatilesets'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32375
diff
changeset
|
1297 |
_clearobsstore(repo) |
20205
d67a7758da6d
perf: fix perfvolatilesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20178
diff
changeset
|
1298 |
repoview.filterrevs(repo, name) |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
1299 |
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
|
1300 |
|
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
1301 |
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
|
1302 |
if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
1303 |
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
|
1304 |
|
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
1305 |
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
|
1306 |
timer(getfiltered(name), title=name) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1307 |
fm.end() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1308 |
|
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1309 |
@command('perfbranchmap', |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1310 |
[('f', 'full', False, |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1311 |
'Includes build time of subset'), |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1312 |
] + formatteropts) |
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1313 |
def perfbranchmap(ui, repo, full=False, **opts): |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1314 |
"""benchmark the update of a branchmap |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1315 |
|
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1316 |
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
|
1317 |
""" |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1318 |
timer, fm = gettimer(ui, opts) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1319 |
def getbranchmap(filtername): |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1320 |
"""generate a benchmark function for the filtername""" |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1321 |
if filtername is None: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1322 |
view = repo |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1323 |
else: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1324 |
view = repo.filtered(filtername) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1325 |
def d(): |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1326 |
if full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1327 |
view._branchcaches.clear() |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1328 |
else: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1329 |
view._branchcaches.pop(filtername, None) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1330 |
view.branchmap() |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1331 |
return d |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1332 |
# 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
|
1333 |
possiblefilters = set(repoview.filtertable) |
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
1334 |
subsettable = getbranchmapsubsettable() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1335 |
allfilters = [] |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1336 |
while possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1337 |
for name in possiblefilters: |
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
1338 |
subset = subsettable.get(name) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1339 |
if subset not in possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1340 |
break |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1341 |
else: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1342 |
assert False, 'subset cycle %s!' % possiblefilters |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1343 |
allfilters.append(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1344 |
possiblefilters.remove(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1345 |
|
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1346 |
# warm the cache |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1347 |
if not full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1348 |
for name in allfilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1349 |
repo.filtered(name).branchmap() |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1350 |
# add unfiltered |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1351 |
allfilters.append(None) |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
1352 |
|
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
1353 |
branchcacheread = safeattrsetter(branchmap, 'read') |
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
1354 |
branchcachewrite = safeattrsetter(branchmap.branchcache, 'write') |
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
1355 |
branchcacheread.set(lambda repo: None) |
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
1356 |
branchcachewrite.set(lambda bc, repo: None) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1357 |
try: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1358 |
for name in allfilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1359 |
timer(getbranchmap(name), title=str(name)) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
1360 |
finally: |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
1361 |
branchcacheread.restore() |
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
1362 |
branchcachewrite.restore() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1363 |
fm.end() |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1364 |
|
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1365 |
@command('perfloadmarkers') |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1366 |
def perfloadmarkers(ui, repo): |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1367 |
"""benchmark the time to parse the on-disk markers for a repo |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1368 |
|
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1369 |
Result is the number of markers in the repo.""" |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1370 |
timer, fm = gettimer(ui) |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
1371 |
svfs = getsvfs(repo) |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30145
diff
changeset
|
1372 |
timer(lambda: len(obsolete.obsstore(svfs))) |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
1373 |
fm.end() |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1374 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1375 |
@command('perflrucachedict', formatteropts + |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1376 |
[('', 'size', 4, 'size of cache'), |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1377 |
('', 'gets', 10000, 'number of key lookups'), |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1378 |
('', 'sets', 10000, 'number of key sets'), |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1379 |
('', 'mixed', 10000, 'number of mixed mode operations'), |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1380 |
('', 'mixedgetfreq', 50, 'frequency of get vs set ops in mixed mode')], |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1381 |
norepo=True) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1382 |
def perflrucache(ui, size=4, gets=10000, sets=10000, mixed=10000, |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1383 |
mixedgetfreq=50, **opts): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1384 |
def doinit(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1385 |
for i in xrange(10000): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1386 |
util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1387 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1388 |
values = [] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1389 |
for i in xrange(size): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1390 |
values.append(random.randint(0, sys.maxint)) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1391 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1392 |
# Get mode fills the cache and tests raw lookup performance with no |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1393 |
# eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1394 |
getseq = [] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1395 |
for i in xrange(gets): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1396 |
getseq.append(random.choice(values)) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1397 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1398 |
def dogets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1399 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1400 |
for v in values: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1401 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1402 |
for key in getseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1403 |
value = d[key] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1404 |
value # silence pyflakes warning |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1405 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1406 |
# Set mode tests insertion speed with cache eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1407 |
setseq = [] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1408 |
for i in xrange(sets): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1409 |
setseq.append(random.randint(0, sys.maxint)) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1410 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1411 |
def dosets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1412 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1413 |
for v in setseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1414 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1415 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1416 |
# Mixed mode randomly performs gets and sets with eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1417 |
mixedops = [] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1418 |
for i in xrange(mixed): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1419 |
r = random.randint(0, 100) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1420 |
if r < mixedgetfreq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1421 |
op = 0 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1422 |
else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1423 |
op = 1 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1424 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1425 |
mixedops.append((op, random.randint(0, size * 2))) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1426 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1427 |
def domixed(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1428 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1429 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1430 |
for op, v in mixedops: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1431 |
if op == 0: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1432 |
try: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1433 |
d[v] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1434 |
except KeyError: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1435 |
pass |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1436 |
else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1437 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1438 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1439 |
benches = [ |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1440 |
(doinit, 'init'), |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1441 |
(dogets, 'gets'), |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1442 |
(dosets, 'sets'), |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1443 |
(domixed, 'mixed') |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1444 |
] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1445 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1446 |
for fn, title in benches: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1447 |
timer, fm = gettimer(ui, opts) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1448 |
timer(fn, title=title) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
1449 |
fm.end() |
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1450 |
|
30977
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1451 |
@command('perfwrite', formatteropts) |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1452 |
def perfwrite(ui, repo, **opts): |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1453 |
"""microbenchmark ui.write |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1454 |
""" |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1455 |
timer, fm = gettimer(ui, opts) |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1456 |
def write(): |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1457 |
for i in range(100000): |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1458 |
ui.write(('Testing write performance\n')) |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1459 |
timer(write) |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1460 |
fm.end() |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
1461 |
|
29495
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1462 |
def uisetup(ui): |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1463 |
if (util.safehasattr(cmdutil, 'openrevlog') and |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1464 |
not util.safehasattr(commands, 'debugrevlogopts')): |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1465 |
# for "historical portability": |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1466 |
# In this case, Mercurial should be 1.9 (or a79fea6b3e77) - |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1467 |
# 3.7 (or 5606f7d0d063). Therefore, '--dir' option for |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1468 |
# openrevlog() should cause failure, because it has been |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1469 |
# available since 3.5 (or 49c583ca48c4). |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1470 |
def openrevlog(orig, repo, cmd, file_, opts): |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1471 |
if opts.get('dir') and not util.safehasattr(repo, 'dirlog'): |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1472 |
raise error.Abort("This version doesn't support --dir option", |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1473 |
hint="use 3.5 or later") |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1474 |
return orig(repo, cmd, file_, opts) |
f83445296213
perf: use locally defined revlog option list for Mercurial earlier than 3.7
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29494
diff
changeset
|
1475 |
extensions.wrapfunction(cmdutil, 'openrevlog', openrevlog) |