Mercurial > hg
annotate contrib/perf.py @ 42712:cdf0e9523de1
branchmap: explicitly warm+write all subsets of the branchmap caches
'full' claims it will warm all of the caches that are known about, but this was
not the case - it did not actually warm the branchmap caches for subsets that we
haven't requested, or for subsets that are still considered "valid". By
explicitly writing them to disk, we can force the subsets for ex: "served" to be
written ("immutable" and "base"), making it cheaper to calculate "served" the
next time it needs to be updated.
Differential Revision: https://phab.mercurial-scm.org/D6710
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Mon, 05 Aug 2019 13:31:12 -0700 |
parents | bc4373babd04 |
children | 9f2189b6bf2a |
rev | line source |
---|---|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # perf.py - performance test routines |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
2 '''helper extension to measure performance |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
3 |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
4 Configurations |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
5 ============== |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
6 |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
7 ``perf`` |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
8 -------- |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
9 |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
10 ``all-timing`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
11 When set, additional statistics will be reported for each benchmark: best, |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
12 worst, median average. If not set only the best timing is reported |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
13 (default: off). |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
14 |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
15 ``presleep`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
16 number of second to wait before any group of runs (default: 1) |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
17 |
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
18 ``pre-run`` |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
19 number of run to perform before starting measurement. |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
20 |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
21 ``profile-benchmark`` |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
22 Enable profiling for the benchmarked section. |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
23 (The first iteration is benchmarked) |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
24 |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
25 ``run-limits`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
26 Control the number of runs each benchmark will perform. The option value |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
27 should be a list of `<time>-<numberofrun>` pairs. After each run the |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
28 conditions are considered in order with the following logic: |
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
29 |
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
30 If benchmark has been running for <time> seconds, and we have performed |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
31 <numberofrun> iterations, stop the benchmark, |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
32 |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
33 The default value is: `3.0-100, 10.0-3` |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
34 |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
35 ``stub`` |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
36 When set, benchmarks will only be run once, useful for testing |
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
37 (default: off) |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41652
diff
changeset
|
38 ''' |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
39 |
29493
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
40 # "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
|
41 # |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
42 # We have to do: |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
43 # - 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
|
44 # 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
|
45 # 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
|
46 # - 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
|
47 # version as possible |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
48 # |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
49 # 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
|
50 # - 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
|
51 # with early Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
52 # |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
53 # 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
|
54 # - 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
|
55 # Mercurial |
4533f5b47949
perf: add historical portability policy for future reference
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28561
diff
changeset
|
56 |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
57 from __future__ import absolute_import |
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
58 import contextlib |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
59 import functools |
31397
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30977
diff
changeset
|
60 import gc |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
61 import os |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
62 import random |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
63 import shutil |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
64 import struct |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
65 import sys |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
66 import tempfile |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
67 import threading |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
68 import time |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
69 from mercurial import ( |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
70 changegroup, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
71 cmdutil, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
72 commands, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
73 copies, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
74 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
|
75 extensions, |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
76 hg, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
77 mdiff, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
78 merge, |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
79 revlog, |
28561
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
80 util, |
330584235c22
contrib: make perf.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27649
diff
changeset
|
81 ) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
82 |
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
|
83 # for "historical portability": |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
84 # 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
|
85 # 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
|
86 try: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
87 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
|
88 except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
89 pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
90 try: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
91 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
|
92 except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
93 pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
94 try: |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
95 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
|
96 dir(registrar) # forcibly load it |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
97 except ImportError: |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
98 registrar = None |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
99 try: |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
100 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
|
101 except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
102 pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
103 try: |
42138
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
104 from mercurial.utils import repoviewutil # since 5.0 |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
105 except ImportError: |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
106 repoviewutil = None |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
107 try: |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
108 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
|
109 except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
110 pass |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
111 try: |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
112 from mercurial import setdiscovery # since 1.9 (or cb98fed52495) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
113 except ImportError: |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
114 pass |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
115 |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
116 try: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
117 from mercurial import profiling |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
118 except ImportError: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
119 profiling = None |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
120 |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
121 def identity(a): |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
122 return a |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
123 |
36178
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
124 try: |
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
125 from mercurial import pycompat |
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
126 getargspec = pycompat.getargspec # added to module after 4.5 |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
127 _byteskwargs = pycompat.byteskwargs # since 4.1 (or fbc3f73dc802) |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
128 _sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
129 _xrange = pycompat.xrange # since 4.8 (or 7eba8f83129b) |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
130 fsencode = pycompat.fsencode # since 3.9 (or f4a5e0e86a7e) |
39823
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
131 if pycompat.ispy3: |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
132 _maxint = sys.maxsize # per py3 docs for replacing maxint |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
133 else: |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
134 _maxint = sys.maxint |
36178
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
135 except (ImportError, AttributeError): |
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
136 import inspect |
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35951
diff
changeset
|
137 getargspec = inspect.getargspec |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
138 _byteskwargs = identity |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
139 fsencode = identity # no py3 support |
39823
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
140 _maxint = sys.maxint # no py3 support |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
141 _sysstr = lambda x: x # no py3 support |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
142 _xrange = xrange |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
143 |
37844
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
144 try: |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
145 # 4.7+ |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
146 queue = pycompat.queue.Queue |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
147 except (AttributeError, ImportError): |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
148 # <4.7. |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
149 try: |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
150 queue = pycompat.queue |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
151 except (AttributeError, ImportError): |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
152 queue = util.queue |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
153 |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
154 try: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
155 from mercurial import logcmdutil |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
156 makelogtemplater = logcmdutil.maketemplater |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
157 except (AttributeError, ImportError): |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
158 try: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
159 makelogtemplater = cmdutil.makelogtemplater |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
160 except (AttributeError, ImportError): |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
161 makelogtemplater = None |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
162 |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
163 # 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
|
164 # 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
|
165 # 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
|
166 _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
|
167 def safehasattr(thing, attr): |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
168 return getattr(thing, _sysstr(attr), _undefined) is not _undefined |
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
|
169 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
|
170 |
29496
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
171 # for "historical portability": |
31823
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
172 # 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
|
173 # since ae5d60bb70c9 |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
174 if safehasattr(time, 'perf_counter'): |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
175 util.timer = time.perf_counter |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
176 elif os.name == b'nt': |
31823
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
177 util.timer = time.clock |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
178 else: |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
179 util.timer = time.time |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
180 |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31476
diff
changeset
|
181 # 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
|
182 # 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
|
183 # 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
|
184 # 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
|
185 # 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
|
186 formatteropts = getattr(cmdutil, "formatteropts", |
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
187 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
|
188 |
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
|
189 # 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
|
190 # 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
|
191 # 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
|
192 # 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
|
193 # 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
|
194 revlogopts = getattr(cmdutil, "debugrevlogopts", |
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
195 getattr(commands, "debugrevlogopts", [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
196 (b'c', b'changelog', False, (b'open changelog')), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
197 (b'm', b'manifest', False, (b'open manifest')), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
198 (b'', b'dir', False, (b'open directory manifest')), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
199 ])) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
200 |
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
201 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
|
202 |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
203 # 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
|
204 # 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
|
205 # 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
|
206 def parsealiases(cmd): |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40214
diff
changeset
|
207 return cmd.split(b"|") |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
208 |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
209 if safehasattr(registrar, 'command'): |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
210 command = registrar.command(cmdtable) |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32297
diff
changeset
|
211 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
|
212 command = cmdutil.command(cmdtable) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
213 if b'norepo' not in getargspec(command).args: |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
214 # 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
|
215 # 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
|
216 # 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
|
217 _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
|
218 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
|
219 if norepo: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
220 commands.norepo += b' %s' % b' '.join(parsealiases(name)) |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
221 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
|
222 else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
223 # 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
|
224 # 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
|
225 # 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
231 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
|
232 if norepo: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
233 commands.norepo += b' %s' % b' '.join(parsealiases(name)) |
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
234 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
|
235 return decorator |
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
236 |
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
237 try: |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
238 import mercurial.registrar |
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
239 import mercurial.configitems |
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
240 configtable = {} |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
241 configitem = mercurial.registrar.configitem(configtable) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
242 configitem(b'perf', b'presleep', |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
243 default=mercurial.configitems.dynamicdefault, |
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
244 ) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
245 configitem(b'perf', b'stub', |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
246 default=mercurial.configitems.dynamicdefault, |
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
247 ) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
248 configitem(b'perf', b'parentscount', |
34750
caf6c446cbe3
contrib-perf: register the 'parentscount' config item
Boris Feld <boris.feld@octobus.net>
parents:
34749
diff
changeset
|
249 default=mercurial.configitems.dynamicdefault, |
caf6c446cbe3
contrib-perf: register the 'parentscount' config item
Boris Feld <boris.feld@octobus.net>
parents:
34749
diff
changeset
|
250 ) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
251 configitem(b'perf', b'all-timing', |
38694
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
252 default=mercurial.configitems.dynamicdefault, |
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
253 ) |
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
254 configitem(b'perf', b'pre-run', |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
255 default=mercurial.configitems.dynamicdefault, |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
256 ) |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
257 configitem(b'perf', b'profile-benchmark', |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
258 default=mercurial.configitems.dynamicdefault, |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
259 ) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
260 configitem(b'perf', b'run-limits', |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
261 default=mercurial.configitems.dynamicdefault, |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
262 ) |
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
263 except (ImportError, AttributeError): |
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
264 pass |
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34343
diff
changeset
|
265 |
27307 | 266 def getlen(ui): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
267 if ui.configbool(b"perf", b"stub", False): |
27307 | 268 return lambda x: 1 |
269 return len | |
270 | |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
271 class noop(object): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
272 """dummy context manager""" |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
273 def __enter__(self): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
274 pass |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
275 def __exit__(self, *args): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
276 pass |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
277 |
42364
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
278 NOOPCTX = noop() |
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
279 |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
280 def gettimer(ui, opts=None): |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
281 """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
|
282 |
27303
57bd9c5431a5
perf: improve grammar of gettimer comment
timeless <timeless@mozdev.org>
parents:
27286
diff
changeset
|
283 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
|
284 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
|
285 |
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
286 # 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
|
287 # experimental config: perf.presleep |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
288 time.sleep(getint(ui, b"perf", b"presleep", 1)) |
23788
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
289 |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
290 if opts is None: |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
291 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
|
292 # 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
|
293 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
|
294 ui = ui.copy() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
295 uifout = safeattrsetter(ui, b'fout', ignoremissing=True) |
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
|
296 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
|
297 # 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
|
298 # 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
|
299 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
|
300 |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
301 # 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
|
302 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
|
303 if uiformatter: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
304 fm = uiformatter(b'perf', opts) |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
305 else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
306 # 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
|
307 # 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
|
308 # 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
|
309 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
|
310 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
|
311 """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
|
312 """ |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
313 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
|
314 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
|
315 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
|
316 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
|
317 else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
318 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
|
319 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
|
320 return False |
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31397
diff
changeset
|
321 __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
|
322 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
|
323 pass |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
324 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
|
325 pass |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 if cond: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
330 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
|
331 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
|
332 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
|
333 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
|
334 pass |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
335 fm = defaultformatter(ui, b'perf', opts) |
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
336 |
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
337 # 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
|
338 # experimental config: perf.stub |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
339 if ui.configbool(b"perf", b"stub", False): |
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
340 return functools.partial(stub_timer, fm), fm |
38694
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
341 |
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
342 # experimental config: perf.all-timing |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
343 displayall = ui.configbool(b"perf", b"all-timing", False) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
344 |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
345 # experimental config: perf.run-limits |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
346 limitspec = ui.configlist(b"perf", b"run-limits", []) |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
347 limits = [] |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
348 for item in limitspec: |
42063
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
349 parts = item.split(b'-', 1) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
350 if len(parts) < 2: |
42063
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
351 ui.warn((b'malformatted run limit entry, missing "-": %s\n' |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
352 % item)) |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
353 continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
354 try: |
42063
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
355 time_limit = float(pycompat.sysstr(parts[0])) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
356 except ValueError as e: |
42063
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
357 ui.warn((b'malformatted run limit entry, %s: %s\n' |
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
358 % (pycompat.bytestr(e), item))) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
359 continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
360 try: |
42063
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
361 run_limit = int(pycompat.sysstr(parts[1])) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
362 except ValueError as e: |
42063
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
363 ui.warn((b'malformatted run limit entry, %s: %s\n' |
912d82daeda3
perf: make perf.run-limits code work with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42021
diff
changeset
|
364 % (pycompat.bytestr(e), item))) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
365 continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
366 limits.append((time_limit, run_limit)) |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
367 if not limits: |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
368 limits = DEFAULTLIMITS |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
369 |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
370 profiler = None |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
371 if profiling is not None: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
372 if ui.configbool(b"perf", b"profile-benchmark", False): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
373 profiler = profiling.profile(ui) |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
374 |
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
375 prerun = getint(ui, b"perf", b"pre-run", 0) |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
376 t = functools.partial(_timer, fm, displayall=displayall, limits=limits, |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
377 prerun=prerun, profiler=profiler) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
378 return t, fm |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
379 |
40680
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40679
diff
changeset
|
380 def stub_timer(fm, func, setup=None, title=None): |
40721
0adc2c0a0792
perf: run 'setup' function during stub run
Boris Feld <boris.feld@octobus.net>
parents:
40720
diff
changeset
|
381 if setup is not None: |
0adc2c0a0792
perf: run 'setup' function during stub run
Boris Feld <boris.feld@octobus.net>
parents:
40720
diff
changeset
|
382 setup() |
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
383 func() |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
384 |
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
385 @contextlib.contextmanager |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
386 def timeone(): |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
387 r = [] |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
388 ostart = os.times() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
389 cstart = util.timer() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
390 yield r |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
391 cstop = util.timer() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
392 ostop = os.times() |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
393 a, b = ostart, ostop |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
394 r.append((cstop - cstart, b[0] - a[0], b[1]-a[1])) |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
395 |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
396 |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
397 # list of stop condition (elapsed time, minimal run count) |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
398 DEFAULTLIMITS = ( |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
399 (3.0, 100), |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
400 (10.0, 3), |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
401 ) |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
402 |
42018
0e6422942c84
perf: pass limits as a function argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42017
diff
changeset
|
403 def _timer(fm, func, setup=None, title=None, displayall=False, |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
404 limits=DEFAULTLIMITS, prerun=0, profiler=None): |
31397
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30977
diff
changeset
|
405 gc.collect() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
406 results = [] |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30882
diff
changeset
|
407 begin = util.timer() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
408 count = 0 |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
409 if profiler is None: |
42364
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
410 profiler = NOOPCTX |
42370
c2d10506725c
py3: use range() instead of xrange()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42364
diff
changeset
|
411 for i in range(prerun): |
42359
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
412 if setup is not None: |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
413 setup() |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
414 func() |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
415 keepgoing = True |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
416 while keepgoing: |
40680
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40679
diff
changeset
|
417 if setup is not None: |
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40679
diff
changeset
|
418 setup() |
42360
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
419 with profiler: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
420 with timeone() as item: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42359
diff
changeset
|
421 r = func() |
42364
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42360
diff
changeset
|
422 profiler = NOOPCTX |
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
423 count += 1 |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
424 results.append(item[0]) |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30882
diff
changeset
|
425 cstop = util.timer() |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
426 # Look for a stop condition. |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
427 elapsed = cstop - begin |
42018
0e6422942c84
perf: pass limits as a function argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42017
diff
changeset
|
428 for t, mincount in limits: |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
429 if elapsed >= t and count >= mincount: |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
430 keepgoing = False |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
431 break |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
432 |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
433 formatone(fm, results, title=title, result=r, |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
434 displayall=displayall) |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
435 |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
436 def formatone(fm, timings, title=None, result=None, displayall=False): |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
437 |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
438 count = len(timings) |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
439 |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
440 fm.startitem() |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
441 |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
442 if title: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
443 fm.write(b'title', b'! %s\n', title) |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
444 if result: |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
445 fm.write(b'result', b'! result: %s\n', result) |
38694
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
446 def display(role, entry): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
447 prefix = b'' |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
448 if role != b'best': |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
449 prefix = b'%s.' % role |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
450 fm.plain(b'!') |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
451 fm.write(prefix + b'wall', b' wall %f', entry[0]) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
452 fm.write(prefix + b'comb', b' comb %f', entry[1] + entry[2]) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
453 fm.write(prefix + b'user', b' user %f', entry[1]) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
454 fm.write(prefix + b'sys', b' sys %f', entry[2]) |
40141 | 455 fm.write(prefix + b'count', b' (%s of %%d)' % role, count) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
456 fm.plain(b'\n') |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
457 timings.sort() |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
458 min_val = timings[0] |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
459 display(b'best', min_val) |
38694
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
460 if displayall: |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
461 max_val = timings[-1] |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
462 display(b'max', max_val) |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
463 avg = tuple([sum(x) / count for x in zip(*timings)]) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
464 display(b'avg', avg) |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
465 median = timings[len(timings) // 2] |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
466 display(b'median', median) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
467 |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
468 # utilities for historical portability |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
469 |
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
|
470 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
|
471 # 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
|
472 # 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
|
473 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
|
474 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
|
475 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
|
476 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
|
477 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
|
478 except ValueError: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
479 raise error.ConfigError((b"%s.%s is not an integer ('%s')") |
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
|
480 % (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
|
481 |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
482 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
|
483 """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
|
484 |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
485 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
|
486 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
|
487 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
|
488 |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
489 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
|
490 (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
|
491 |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
492 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
|
493 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
|
494 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
|
495 versions. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
496 """ |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
497 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
|
498 if ignoremissing: |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
499 return None |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
500 raise error.Abort((b"missing attribute %s of %s might break assumption" |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
501 b" of performance measurement") % (name, obj)) |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
502 |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
503 origvalue = getattr(obj, _sysstr(name)) |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
504 class attrutil(object): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
505 def set(self, newvalue): |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
506 setattr(obj, _sysstr(name), newvalue) |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
507 def restore(self): |
39821
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
508 setattr(obj, _sysstr(name), origvalue) |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
509 |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
510 return attrutil() |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
511 |
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
|
512 # 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
|
513 |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
514 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
|
515 # 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
|
516 # 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
|
517 # - 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
|
518 # - repoview since 2.5 (or 59a9f18d4587) |
42138
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
519 # - repoviewutil since 5.0 |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
520 for mod in (branchmap, repoview, repoviewutil): |
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
|
521 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
|
522 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
|
523 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
|
524 |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
525 # 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
|
526 # 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
|
527 # doesn't) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
528 raise error.Abort((b"perfbranchmap not available with this Mercurial"), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
529 hint=b"use 2.5 or later") |
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
|
530 |
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
|
531 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
|
532 """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
|
533 """ |
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
|
534 # 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
|
535 # 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 |
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
|
542 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
|
543 """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
|
544 """ |
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
|
545 # 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
|
546 # 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
553 def repocleartagscachefunc(repo): |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
554 """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
|
555 """ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
556 if util.safehasattr(repo, b'_tagscache'): # since 2.0 (or 9dca7653b525) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
557 # 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
|
558 # 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
|
559 # 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
|
560 def clearcache(): |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
561 # _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
|
562 # 98c867ac1330), and delattr() can't work in such case |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
563 if b'_tagscache' in vars(repo): |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
564 del repo.__dict__[b'_tagscache'] |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
565 return clearcache |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
566 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
567 repotags = safeattrsetter(repo, b'_tags', ignoremissing=True) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
568 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
|
569 return lambda : repotags.set(None) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
570 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
571 repotagscache = safeattrsetter(repo, b'tagscache', ignoremissing=True) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
572 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
|
573 return lambda : repotagscache.set(None) |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
574 |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
575 # 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
|
576 # 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
|
577 # - 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
|
578 # in perftags() causes failure soon |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
579 # - perf.py itself has been available since 1.1 (or eb240755386d) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
580 raise error.Abort((b"tags API of this hg command is unknown")) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
581 |
32731
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32710
diff
changeset
|
582 # utilities to clear cache |
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32710
diff
changeset
|
583 |
40683
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
584 def clearfilecache(obj, attrname): |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
585 unfiltered = getattr(obj, 'unfiltered', None) |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
586 if unfiltered is not None: |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
587 obj = obj.unfiltered() |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
588 if attrname in vars(obj): |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
589 delattr(obj, attrname) |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40682
diff
changeset
|
590 obj._filecache.pop(attrname, None) |
32731
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32710
diff
changeset
|
591 |
40701
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
592 def clearchangelog(repo): |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
593 if repo is not repo.unfiltered(): |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
594 object.__setattr__(repo, r'_clcachekey', None) |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
595 object.__setattr__(repo, r'_clcache', None) |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
596 clearfilecache(repo.unfiltered(), 'changelog') |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40700
diff
changeset
|
597 |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
598 # perf commands |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
599 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
600 @command(b'perfwalk', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
601 def perfwalk(ui, repo, *pats, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
602 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
603 timer, fm = gettimer(ui, opts) |
34342
b3538c03a804
perf: remove fallbacks to ancient versions of dirstate.walk()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32888
diff
changeset
|
604 m = scmutil.match(repo[None], pats, {}) |
34343
255c761a52db
dirstate: use keyword arguments to clarify walk()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34342
diff
changeset
|
605 timer(lambda: len(list(repo.dirstate.walk(m, subrepos=[], unknown=True, |
255c761a52db
dirstate: use keyword arguments to clarify walk()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34342
diff
changeset
|
606 ignored=False)))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
607 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
608 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
609 @command(b'perfannotate', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
610 def perfannotate(ui, repo, f, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
611 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
612 timer, fm = gettimer(ui, opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
613 fc = repo[b'.'][f] |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
614 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
|
615 fm.end() |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
616 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
617 @command(b'perfstatus', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
618 [(b'u', b'unknown', False, |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
619 b'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
|
620 def perfstatus(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
621 opts = _byteskwargs(opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
622 #m = match.always(repo.root, repo.getcwd()) |
16683 | 623 #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, |
624 # False)))) | |
27017
cdc3e437b481
perf: un-bitrot perfstatus
Matt Mackall <mpm@selenic.com>
parents:
26748
diff
changeset
|
625 timer, fm = gettimer(ui, opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
626 timer(lambda: sum(map(len, repo.status(unknown=opts[b'unknown'])))) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
627 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
628 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
629 @command(b'perfaddremove', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
630 def perfaddremove(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
631 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
632 timer, fm = gettimer(ui, opts) |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
633 try: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
634 oldquiet = repo.ui.quiet |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
635 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
|
636 matcher = scmutil.match(repo[None]) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
637 opts[b'dry_run'] = True |
41652
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
638 if b'uipathfn' in getargspec(scmutil.addremove).args: |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
639 uipathfn = scmutil.getuipathfn(repo) |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
640 timer(lambda: scmutil.addremove(repo, matcher, b"", uipathfn, opts)) |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
641 else: |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41615
diff
changeset
|
642 timer(lambda: scmutil.addremove(repo, matcher, b"", opts)) |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
643 finally: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
644 repo.ui.quiet = oldquiet |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
645 fm.end() |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
646 |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
647 def clearcaches(cl): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
648 # behave somewhat consistently across internal API changes |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
649 if util.safehasattr(cl, b'clearcaches'): |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
650 cl.clearcaches() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
651 elif util.safehasattr(cl, b'_nodecache'): |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
652 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
|
653 cl._nodecache = {nullid: nullrev} |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
654 cl._nodepos = None |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
655 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
656 @command(b'perfheads', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
657 def perfheads(ui, repo, **opts): |
41434
48394923fbdc
perf: document perfheads
Boris Feld <boris.feld@octobus.net>
parents:
41365
diff
changeset
|
658 """benchmark the computation of a changelog heads""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
659 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
660 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
|
661 cl = repo.changelog |
41436
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41434
diff
changeset
|
662 def s(): |
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41434
diff
changeset
|
663 clearcaches(cl) |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
664 def d(): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
665 len(cl.headrevs()) |
41436
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41434
diff
changeset
|
666 timer(d, setup=s) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
667 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
668 |
40744
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
669 @command(b'perftags', formatteropts+ |
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
670 [ |
40747
380a1f73830f
perf: disable revlogs clearing in `perftags` by default
Boris Feld <boris.feld@octobus.net>
parents:
40746
diff
changeset
|
671 (b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
40744
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
672 ]) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
673 def perftags(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
674 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
675 timer, fm = gettimer(ui, opts) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
676 repocleartagscache = repocleartagscachefunc(repo) |
40744
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
677 clearrevlogs = opts[b'clear_revlogs'] |
40682
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40681
diff
changeset
|
678 def s(): |
40744
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
679 if clearrevlogs: |
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
680 clearchangelog(repo) |
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40743
diff
changeset
|
681 clearfilecache(repo.unfiltered(), 'manifest') |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
682 repocleartagscache() |
40682
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40681
diff
changeset
|
683 def t(): |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
684 return len(repo.tags()) |
40682
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40681
diff
changeset
|
685 timer(t, setup=s) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
686 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
687 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
688 @command(b'perfancestors', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
689 def perfancestors(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
690 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
691 timer, fm = gettimer(ui, opts) |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
692 heads = repo.changelog.headrevs() |
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
693 def d(): |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16858
diff
changeset
|
694 for a in repo.changelog.ancestors(heads): |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
695 pass |
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
696 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
697 fm.end() |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
698 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
699 @command(b'perfancestorset', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
700 def perfancestorset(ui, repo, revset, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
701 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
702 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
|
703 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
|
704 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
|
705 def d(): |
18091
f7f8159caad3
ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents:
18080
diff
changeset
|
706 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
|
707 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
|
708 rev in s |
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
709 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
710 fm.end() |
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
711 |
40941
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
712 @command(b'perfdiscovery', formatteropts, b'PATH') |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
713 def perfdiscovery(ui, repo, path, **opts): |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
714 """benchmark discovery between local repo and the peer at given path |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
715 """ |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
716 repos = [repo, None] |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
717 timer, fm = gettimer(ui, opts) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
718 path = ui.expandpath(path) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
719 |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
720 def s(): |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
721 repos[1] = hg.peer(ui, opts, path) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
722 def d(): |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
723 setdiscovery.findcommonheads(ui, *repos) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
724 timer(d, setup=s) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
725 fm.end() |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40925
diff
changeset
|
726 |
40746
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
727 @command(b'perfbookmarks', formatteropts + |
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
728 [ |
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
729 (b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
730 ]) |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
731 def perfbookmarks(ui, repo, **opts): |
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
732 """benchmark parsing bookmarks from disk to memory""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
733 opts = _byteskwargs(opts) |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
734 timer, fm = gettimer(ui, opts) |
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
735 |
40746
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
736 clearrevlogs = opts[b'clear_revlogs'] |
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
737 def s(): |
40746
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
738 if clearrevlogs: |
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40744
diff
changeset
|
739 clearchangelog(repo) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
740 clearfilecache(repo, b'_bookmarks') |
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
741 def d(): |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
742 repo._bookmarks |
40681
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40680
diff
changeset
|
743 timer(d, setup=s) |
32733
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
744 fm.end() |
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32732
diff
changeset
|
745 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
746 @command(b'perfbundleread', formatteropts, b'BUNDLE') |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
747 def perfbundleread(ui, repo, bundlepath, **opts): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
748 """Benchmark reading of bundle files. |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
749 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
750 This command is meant to isolate the I/O part of bundle reading as |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
751 much as possible. |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
752 """ |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
753 from mercurial import ( |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
754 bundle2, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
755 exchange, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
756 streamclone, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
757 ) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
758 |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
759 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
760 |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
761 def makebench(fn): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
762 def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
763 with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
764 bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
765 fn(bundle) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
766 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
767 return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
768 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
769 def makereadnbytes(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
770 def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
771 with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
772 bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
773 while bundle.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
774 pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
775 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
776 return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
777 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
778 def makestdioread(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
779 def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
780 with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
781 while fh.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
782 pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
783 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
784 return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
785 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
786 # bundle1 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
787 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
788 def deltaiter(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
789 for delta in bundle.deltaiter(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
790 pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
791 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
792 def iterchunks(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
793 for chunk in bundle.getchunks(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
794 pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
795 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
796 # bundle2 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
797 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
798 def forwardchunks(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
799 for chunk in bundle._forwardchunks(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
800 pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
801 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
802 def iterparts(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
803 for part in bundle.iterparts(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
804 pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
805 |
35116
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
806 def iterpartsseekable(bundle): |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
807 for part in bundle.iterparts(seekable=True): |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
808 pass |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
809 |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
810 def seek(bundle): |
35116
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35109
diff
changeset
|
811 for part in bundle.iterparts(seekable=True): |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
812 part.seek(0, os.SEEK_END) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
813 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
814 def makepartreadnbytes(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
815 def run(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
816 with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
817 bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
818 for part in bundle.iterparts(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
819 while part.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
820 pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
821 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
822 return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
823 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
824 benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
825 (makestdioread(8192), b'read(8k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
826 (makestdioread(16384), b'read(16k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
827 (makestdioread(32768), b'read(32k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
828 (makestdioread(131072), b'read(128k)'), |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
829 ] |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
830 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
831 with open(bundlepath, b'rb') as fh: |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
832 bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
833 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
834 if isinstance(bundle, changegroup.cg1unpacker): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
835 benches.extend([ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
836 (makebench(deltaiter), b'cg1 deltaiter()'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
837 (makebench(iterchunks), b'cg1 getchunks()'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
838 (makereadnbytes(8192), b'cg1 read(8k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
839 (makereadnbytes(16384), b'cg1 read(16k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
840 (makereadnbytes(32768), b'cg1 read(32k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
841 (makereadnbytes(131072), b'cg1 read(128k)'), |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
842 ]) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
843 elif isinstance(bundle, bundle2.unbundle20): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
844 benches.extend([ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
845 (makebench(forwardchunks), b'bundle2 forwardchunks()'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
846 (makebench(iterparts), b'bundle2 iterparts()'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
847 (makebench(iterpartsseekable), b'bundle2 iterparts() seekable'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
848 (makebench(seek), b'bundle2 part seek()'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
849 (makepartreadnbytes(8192), b'bundle2 part read(8k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
850 (makepartreadnbytes(16384), b'bundle2 part read(16k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
851 (makepartreadnbytes(32768), b'bundle2 part read(32k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
852 (makepartreadnbytes(131072), b'bundle2 part read(128k)'), |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
853 ]) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
854 elif isinstance(bundle, streamclone.streamcloneapplier): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
855 raise error.Abort(b'stream clone bundles not supported') |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
856 else: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
857 raise error.Abort(b'unhandled bundle type: %s' % type(bundle)) |
35109
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
858 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
859 for fn, title in benches: |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
860 timer, fm = gettimer(ui, opts) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
861 timer(fn, title=title) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
862 fm.end() |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35084
diff
changeset
|
863 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
864 @command(b'perfchangegroupchangelog', formatteropts + |
40713
cfaf3843491b
perf: rename version flag of perfchangegroupchangelog to cgversion
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40702
diff
changeset
|
865 [(b'', b'cgversion', b'02', b'changegroup version'), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
866 (b'r', b'rev', b'', b'revisions to add to changegroup')]) |
40713
cfaf3843491b
perf: rename version flag of perfchangegroupchangelog to cgversion
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40702
diff
changeset
|
867 def perfchangegroupchangelog(ui, repo, cgversion=b'02', rev=None, **opts): |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
868 """Benchmark producing a changelog group for a changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
869 |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
870 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
|
871 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
|
872 processing a `getbundle` wire protocol request (handles clones |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
873 and pull requests). |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
874 |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
875 By default, all revisions are added to the changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
876 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
877 opts = _byteskwargs(opts) |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
878 cl = repo.changelog |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
879 nodes = [cl.lookup(r) for r in repo.revs(rev or b'all()')] |
40713
cfaf3843491b
perf: rename version flag of perfchangegroupchangelog to cgversion
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40702
diff
changeset
|
880 bundler = changegroup.getbundler(cgversion, repo) |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
881 |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
882 def d(): |
38977
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
883 state, chunks = bundler._generatechangelog(cl, nodes) |
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
884 for chunk in chunks: |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
885 pass |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
886 |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
887 timer, fm = gettimer(ui, opts) |
38977
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
888 |
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
889 # Terminal printing can interfere with timing. So disable it. |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
890 with ui.configoverride({(b'progress', b'disable'): True}): |
38977
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
891 timer(d) |
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38969
diff
changeset
|
892 |
30018
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
893 fm.end() |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30017
diff
changeset
|
894 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
895 @command(b'perfdirs', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
896 def perfdirs(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
897 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
898 timer, fm = gettimer(ui, opts) |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
899 dirstate = repo.dirstate |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
900 b'a' in dirstate |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
901 def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
902 dirstate.hasdir(b'a') |
35084
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
34750
diff
changeset
|
903 del dirstate._map._dirs |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
904 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
905 fm.end() |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
906 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
907 @command(b'perfdirstate', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
908 def perfdirstate(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
909 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
910 timer, fm = gettimer(ui, opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
911 b"a" in repo.dirstate |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
912 def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
913 repo.dirstate.invalidate() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
914 b"a" in repo.dirstate |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
915 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
916 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
917 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
918 @command(b'perfdirstatedirs', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
919 def perfdirstatedirs(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
920 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
921 timer, fm = gettimer(ui, opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
922 b"a" in repo.dirstate |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
923 def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
924 repo.dirstate.hasdir(b"a") |
35084
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
34750
diff
changeset
|
925 del repo.dirstate._map._dirs |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
926 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
927 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
928 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
929 @command(b'perfdirstatefoldmap', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
930 def perfdirstatefoldmap(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
931 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
932 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
|
933 dirstate = repo.dirstate |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
934 b'a' in dirstate |
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
935 def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
936 dirstate._map.filefoldmap.get(b'a') |
34676
bfddc3d678ae
dirstate: remove _filefoldmap property cache
Durham Goode <durham@fb.com>
parents:
34494
diff
changeset
|
937 del dirstate._map.filefoldmap |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
938 timer(d) |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
939 fm.end() |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
940 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
941 @command(b'perfdirfoldmap', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
942 def perfdirfoldmap(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
943 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
944 timer, fm = gettimer(ui, opts) |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
945 dirstate = repo.dirstate |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
946 b'a' in dirstate |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
947 def d(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
948 dirstate._map.dirfoldmap.get(b'a') |
34678
e8a89ed7ce96
dirstate: move the _dirfoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34677
diff
changeset
|
949 del dirstate._map.dirfoldmap |
35084
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
34750
diff
changeset
|
950 del dirstate._map._dirs |
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
951 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
952 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
|
953 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
954 @command(b'perfdirstatewrite', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
955 def perfdirstatewrite(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
956 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
957 timer, fm = gettimer(ui, opts) |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
958 ds = repo.dirstate |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
959 b"a" in ds |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
960 def d(): |
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
961 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
|
962 ds.write(repo.currenttransaction()) |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
963 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
964 fm.end() |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
965 |
42383
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
966 def _getmergerevs(repo, opts): |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
967 """parse command argument to return rev involved in merge |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
968 |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
969 input: options dictionnary with `rev`, `from` and `bse` |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
970 output: (localctx, otherctx, basectx) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
971 """ |
42392
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
972 if opts[b'from']: |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
973 fromrev = scmutil.revsingle(repo, opts[b'from']) |
42381
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
974 wctx = repo[fromrev] |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
975 else: |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
976 wctx = repo[None] |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
977 # we don't want working dir files to be stat'd in the benchmark, so |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
978 # prime that cache |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42370
diff
changeset
|
979 wctx.dirty() |
42392
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
980 rctx = scmutil.revsingle(repo, opts[b'rev'], opts[b'rev']) |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
981 if opts[b'base']: |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42385
diff
changeset
|
982 fromrev = scmutil.revsingle(repo, opts[b'base']) |
42382
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
983 ancestor = repo[fromrev] |
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
984 else: |
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
985 ancestor = wctx.ancestor(rctx) |
42383
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
986 return (wctx, rctx, ancestor) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
987 |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
988 @command(b'perfmergecalculate', |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
989 [ |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
990 (b'r', b'rev', b'.', b'rev to merge against'), |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
991 (b'', b'from', b'', b'rev to merge from'), |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
992 (b'', b'base', b'', b'the revision to use as base'), |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
993 ] + formatteropts) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
994 def perfmergecalculate(ui, repo, **opts): |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
995 opts = _byteskwargs(opts) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
996 timer, fm = gettimer(ui, opts) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
997 |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
998 wctx, rctx, ancestor = _getmergerevs(repo, opts) |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
999 def d(): |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1000 # 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
|
1001 # our benchmark |
27098
64cb281d23a5
contrib/perf: fix perfmergecalculate
timeless <timeless@mozdev.org>
parents:
27097
diff
changeset
|
1002 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
|
1003 acceptremote=True, followcopies=True) |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1004 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1005 fm.end() |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1006 |
42384
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1007 @command(b'perfmergecopies', |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1008 [ |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1009 (b'r', b'rev', b'.', b'rev to merge against'), |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1010 (b'', b'from', b'', b'rev to merge from'), |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1011 (b'', b'base', b'', b'the revision to use as base'), |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1012 ] + formatteropts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1013 def perfmergecopies(ui, repo, **opts): |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1014 """measure runtime of `copies.mergecopies`""" |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1015 opts = _byteskwargs(opts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1016 timer, fm = gettimer(ui, opts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1017 wctx, rctx, ancestor = _getmergerevs(repo, opts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1018 def d(): |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1019 # acceptremote is True because we don't want prompts in the middle of |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1020 # our benchmark |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1021 copies.mergecopies(repo, wctx, rctx, ancestor) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1022 timer(d) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1023 fm.end() |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42383
diff
changeset
|
1024 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1025 @command(b'perfpathcopies', [], b"REV REV") |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1026 def perfpathcopies(ui, repo, rev1, rev2, **opts): |
40739
dc3ab5e5fe64
perf: add a docstring to `perfpathcopies`
Boris Feld <boris.feld@octobus.net>
parents:
40731
diff
changeset
|
1027 """benchmark the copy tracing logic""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1028 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1029 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
|
1030 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
|
1031 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
|
1032 def d(): |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1033 copies.pathcopies(ctx1, ctx2) |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1034 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1035 fm.end() |
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1036 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1037 @command(b'perfphases', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1038 [(b'', b'full', False, b'include file reading time too'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1039 ], b"") |
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1040 def perfphases(ui, repo, **opts): |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1041 """benchmark phasesets computation""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1042 opts = _byteskwargs(opts) |
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1043 timer, fm = gettimer(ui, opts) |
32732
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1044 _phases = repo._phasecache |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1045 full = opts.get(b'full') |
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1046 def d(): |
32732
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1047 phases = _phases |
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1048 if full: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1049 clearfilecache(repo, b'_phasecache') |
32732
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32731
diff
changeset
|
1050 phases = repo._phasecache |
32467
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1051 phases.invalidate() |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1052 phases.loadphaserevs(repo) |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1053 timer(d) |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1054 fm.end() |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32390
diff
changeset
|
1055 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1056 @command(b'perfphasesremote', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1057 [], b"[DEST]") |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1058 def perfphasesremote(ui, repo, dest=None, **opts): |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1059 """benchmark time needed to analyse phases of the remote server""" |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1060 from mercurial.node import ( |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1061 bin, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1062 ) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1063 from mercurial import ( |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1064 exchange, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1065 hg, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1066 phases, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1067 ) |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1068 opts = _byteskwargs(opts) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1069 timer, fm = gettimer(ui, opts) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1070 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1071 path = ui.paths.getpath(dest, default=(b'default-push', b'default')) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1072 if not path: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1073 raise error.Abort((b'default repository not configured!'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1074 hint=(b"see 'hg help config.paths'")) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1075 dest = path.pushloc or path.loc |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1076 ui.status((b'analysing phase of %s\n') % util.hidepassword(dest)) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1077 other = hg.peer(repo, opts, dest) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1078 |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1079 # easier to perform discovery through the operation |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1080 op = exchange.pushoperation(repo, other) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1081 exchange._pushdiscoverychangeset(op) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1082 |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1083 remotesubset = op.fallbackheads |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1084 |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1085 with other.commandexecutor() as e: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1086 remotephases = e.callcommand(b'listkeys', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1087 {b'namespace': b'phases'}).result() |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1088 del other |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1089 publishing = remotephases.get(b'publishing', False) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1090 if publishing: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1091 ui.status((b'publishing: yes\n')) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1092 else: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1093 ui.status((b'publishing: no\n')) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1094 |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1095 nodemap = repo.changelog.nodemap |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1096 nonpublishroots = 0 |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1097 for nhex, phase in remotephases.iteritems(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1098 if nhex == b'publishing': # ignore data related to publish option |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1099 continue |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1100 node = bin(nhex) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1101 if node in nodemap and int(phase): |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1102 nonpublishroots += 1 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1103 ui.status((b'number of roots: %d\n') % len(remotephases)) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1104 ui.status((b'number of known non public roots: %d\n') % nonpublishroots) |
39140
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1105 def d(): |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1106 phases.remotephasessummary(repo, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1107 remotesubset, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1108 remotephases) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1109 timer(d) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1110 fm.end() |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1111 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1112 @command(b'perfmanifest',[ |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1113 (b'm', b'manifest-rev', False, b'Look up a manifest node revision'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1114 (b'', b'clear-disk', False, b'clear on-disk caches too'), |
40142
25ce80ce84c5
perf: accept formatter option for perfmanifest
Boris Feld <boris.feld@octobus.net>
parents:
40141
diff
changeset
|
1115 ] + formatteropts, b'REV|NODE') |
38780
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1116 def perfmanifest(ui, repo, rev, manifest_rev=False, clear_disk=False, **opts): |
38693
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1117 """benchmark the time to read a manifest from disk and return a usable |
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1118 dict-like object |
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1119 |
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38273
diff
changeset
|
1120 Manifest caches are cleared before retrieval.""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1121 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1122 timer, fm = gettimer(ui, opts) |
38780
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1123 if not manifest_rev: |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1124 ctx = scmutil.revsingle(repo, rev, rev) |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1125 t = ctx.manifestnode() |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38778
diff
changeset
|
1126 else: |
39318
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1127 from mercurial.node import bin |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1128 |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1129 if len(rev) == 40: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1130 t = bin(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1131 else: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1132 try: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1133 rev = int(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1134 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1135 if util.safehasattr(repo.manifestlog, b'getstorage'): |
39318
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1136 t = repo.manifestlog.getstorage(b'').node(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1137 else: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1138 t = repo.manifestlog._revlog.lookup(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39194
diff
changeset
|
1139 except ValueError: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1140 raise error.Abort(b'manifest revision must be integer or full ' |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1141 b'node') |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1142 def d(): |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38780
diff
changeset
|
1143 repo.manifestlog.clearcaches(clear_persisted_data=clear_disk) |
30369
d79c141fdf41
manifest: remove usages of manifest.read
Durham Goode <durham@fb.com>
parents:
30337
diff
changeset
|
1144 repo.manifestlog[t].read() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1145 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1146 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1147 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1148 @command(b'perfchangeset', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1149 def perfchangeset(ui, repo, rev, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1150 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1151 timer, fm = gettimer(ui, opts) |
37355
5bcd5859b505
perf: make perfmanifest and perfnodelookup work with revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37269
diff
changeset
|
1152 n = scmutil.revsingle(repo, rev).node() |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1153 def d(): |
19378
9de689d20230
cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents:
19322
diff
changeset
|
1154 repo.changelog.read(n) |
16266
77d56a5e74a5
perf: add a changeset test
Matt Mackall <mpm@selenic.com>
parents:
16262
diff
changeset
|
1155 #repo.changelog._cache = None |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1156 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1157 fm.end() |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1158 |
40750
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1159 @command(b'perfignore', formatteropts) |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1160 def perfignore(ui, repo, **opts): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1161 """benchmark operation related to computing ignore""" |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1162 opts = _byteskwargs(opts) |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1163 timer, fm = gettimer(ui, opts) |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1164 dirstate = repo.dirstate |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1165 |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1166 def setupone(): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1167 dirstate.invalidate() |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1168 clearfilecache(dirstate, b'_ignore') |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1169 |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1170 def runone(): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1171 dirstate._ignore |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1172 |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1173 timer(runone, setup=setupone, title=b"load") |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1174 fm.end() |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40747
diff
changeset
|
1175 |
40784
a0f2641ddd61
perf: add a --rev attribute to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
40783
diff
changeset
|
1176 @command(b'perfindex', [ |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1177 (b'', b'rev', [], b'revision to be looked up (default tip)'), |
41438
e9891c734bf8
perf: add a no-lookup variant to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41437
diff
changeset
|
1178 (b'', b'no-lookup', None, b'do not revision lookup post creation'), |
40784
a0f2641ddd61
perf: add a --rev attribute to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
40783
diff
changeset
|
1179 ] + formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1180 def perfindex(ui, repo, **opts): |
41437
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1181 """benchmark index creation time followed by a lookup |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1182 |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1183 The default is to look `tip` up. Depending on the index implementation, |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1184 the revision looked up can matters. For example, an implementation |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1185 scanning the index will have a faster lookup time for `--rev tip` than for |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1186 `--rev 0`. The number of looked up revisions and their order can also |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1187 matters. |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1188 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1189 Example of useful set to test: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1190 * tip |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1191 * 0 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1192 * -10: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1193 * :10 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1194 * -10: + :10 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1195 * :10: + -10: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1196 * -10000: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1197 * -10000: + 0 |
41437
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41436
diff
changeset
|
1198 |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1199 It is not currently possible to check for lookup of a missing node. For |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1200 deeper lookup benchmarking, checkout the `perfnodemap` command.""" |
13255
2696730ca233
perf: make perfindex results useful on hg with lazyparser
Matt Mackall <mpm@selenic.com>
parents:
13254
diff
changeset
|
1201 import mercurial.revlog |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1202 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1203 timer, fm = gettimer(ui, opts) |
13277
9f707b297b0f
perf: restore lazyindex hack
Matt Mackall <mpm@selenic.com>
parents:
13262
diff
changeset
|
1204 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
41438
e9891c734bf8
perf: add a no-lookup variant to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41437
diff
changeset
|
1205 if opts[b'no_lookup']: |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1206 if opts['rev']: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1207 raise error.Abort('--no-lookup and --rev are mutually exclusive') |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1208 nodes = [] |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1209 elif not opts[b'rev']: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1210 nodes = [repo[b"tip"].node()] |
40784
a0f2641ddd61
perf: add a --rev attribute to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
40783
diff
changeset
|
1211 else: |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1212 revs = scmutil.revrange(repo, opts[b'rev']) |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1213 cl = repo.changelog |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1214 nodes = [cl.node(r) for r in revs] |
40783
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1215 |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1216 unfi = repo.unfiltered() |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1217 # find the filecache func directly |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1218 # This avoid polluting the benchmark with the filecache logic |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1219 makecl = unfi.__class__.changelog.func |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1220 def setup(): |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1221 # probably not necessary, but for good measure |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1222 clearchangelog(unfi) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1223 def d(): |
40783
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1224 cl = makecl(unfi) |
41439
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41438
diff
changeset
|
1225 for n in nodes: |
41438
e9891c734bf8
perf: add a no-lookup variant to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41437
diff
changeset
|
1226 cl.rev(n) |
40783
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40772
diff
changeset
|
1227 timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1228 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1229 |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1230 @command(b'perfnodemap', [ |
41470
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1231 (b'', b'rev', [], b'revision to be looked up (default tip)'), |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1232 (b'', b'clear-caches', True, b'clear revlog cache between calls'), |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1233 ] + formatteropts) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1234 def perfnodemap(ui, repo, **opts): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1235 """benchmark the time necessary to look up revision from a cold nodemap |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1236 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1237 Depending on the implementation, the amount and order of revision we look |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1238 up can varies. Example of useful set to test: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1239 * tip |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1240 * 0 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1241 * -10: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1242 * :10 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1243 * -10: + :10 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1244 * :10: + -10: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1245 * -10000: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1246 * -10000: + 0 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1247 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1248 The command currently focus on valid binary lookup. Benchmarking for |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1249 hexlookup, prefix lookup and missing lookup would also be valuable. |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1250 """ |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1251 import mercurial.revlog |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1252 opts = _byteskwargs(opts) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1253 timer, fm = gettimer(ui, opts) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1254 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1255 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1256 unfi = repo.unfiltered() |
41470
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1257 clearcaches = opts['clear_caches'] |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1258 # find the filecache func directly |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1259 # This avoid polluting the benchmark with the filecache logic |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1260 makecl = unfi.__class__.changelog.func |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1261 if not opts[b'rev']: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1262 raise error.Abort('use --rev to specify revisions to look up') |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1263 revs = scmutil.revrange(repo, opts[b'rev']) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1264 cl = repo.changelog |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1265 nodes = [cl.node(r) for r in revs] |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1266 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1267 # use a list to pass reference to a nodemap from one closure to the next |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1268 nodeget = [None] |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1269 def setnodeget(): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1270 # probably not necessary, but for good measure |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1271 clearchangelog(unfi) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1272 nodeget[0] = makecl(unfi).nodemap.get |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1273 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1274 def d(): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1275 get = nodeget[0] |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1276 for n in nodes: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1277 get(n) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1278 |
41470
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1279 setup = None |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1280 if clearcaches: |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1281 def setup(): |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1282 setnodeget() |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1283 else: |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1284 setnodeget() |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41469
diff
changeset
|
1285 d() # prewarm the data structure |
41469
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1286 timer(d, setup=setup) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1287 fm.end() |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41439
diff
changeset
|
1288 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1289 @command(b'perfstartup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1290 def perfstartup(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1291 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1292 timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1293 def d(): |
39824
db875f97a969
py3: un-byteify strings around os.system() and os.devnull in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39823
diff
changeset
|
1294 if os.name != r'nt': |
40349
1524c305377f
py3: restore perfstartup() prior to b456b2e0ad9f on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
40295
diff
changeset
|
1295 os.system(b"HGRCPATH= %s version -q > /dev/null" % |
1524c305377f
py3: restore perfstartup() prior to b456b2e0ad9f on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
40295
diff
changeset
|
1296 fsencode(sys.argv[0])) |
27382
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
1297 else: |
39824
db875f97a969
py3: un-byteify strings around os.system() and os.devnull in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39823
diff
changeset
|
1298 os.environ[r'HGRCPATH'] = r' ' |
40349
1524c305377f
py3: restore perfstartup() prior to b456b2e0ad9f on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
40295
diff
changeset
|
1299 os.system(r"%s version -q > NUL" % sys.argv[0]) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1300 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1301 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1302 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1303 @command(b'perfparents', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1304 def perfparents(ui, repo, **opts): |
42016
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
1305 """benchmark the time necessary to fetch one changeset's parents. |
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
1306 |
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
1307 The fetch is done using the `node identifier`, traversing all object layers |
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
1308 from the repository object. The first N revisions will be used for this |
42016
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
1309 benchmark. N is controlled by the ``perf.parentscount`` config option |
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
1310 (default: 1000). |
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
1311 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1312 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1313 timer, fm = gettimer(ui, opts) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
1314 # control the number of commits perfparents iterates over |
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
1315 # experimental config: perf.parentscount |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1316 count = getint(ui, b"perf", b"parentscount", 1000) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
1317 if len(repo.changelog) < count: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1318 raise error.Abort(b"repo needs %d commits for this test" % count) |
27100
8d5dba93aa4f
contrib/perf: perfparents handle filtered repos
timeless <timeless@mozdev.org>
parents:
27099
diff
changeset
|
1319 repo = repo.unfiltered() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
1320 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
|
1321 def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1322 for n in nl: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1323 repo.changelog.parents(n) |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1324 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1325 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1326 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1327 @command(b'perfctxfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
1328 def perfctxfiles(ui, repo, x, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1329 opts = _byteskwargs(opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1330 x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1331 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
|
1332 def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1333 len(repo[x].files()) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1334 timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1335 fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1336 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1337 @command(b'perfrawfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
1338 def perfrawfiles(ui, repo, x, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1339 opts = _byteskwargs(opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1340 x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1341 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
|
1342 cl = repo.changelog |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1343 def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1344 len(cl.read(x)[3]) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1345 timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1346 fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1347 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1348 @command(b'perflookup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1349 def perflookup(ui, repo, rev, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1350 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1351 timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1352 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
|
1353 fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1354 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1355 @command(b'perflinelogedits', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1356 [(b'n', b'edits', 10000, b'number of edits'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1357 (b'', b'max-hunk-lines', 10, b'max lines in a hunk'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1358 ], norepo=True) |
38969
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1359 def perflinelogedits(ui, **opts): |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1360 from mercurial import linelog |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1361 |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1362 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1363 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1364 edits = opts[b'edits'] |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1365 maxhunklines = opts[b'max_hunk_lines'] |
38969
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1366 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1367 maxb1 = 100000 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1368 random.seed(0) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1369 randint = random.randint |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1370 currentlines = 0 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1371 arglist = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
1372 for rev in _xrange(edits): |
38969
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1373 a1 = randint(0, currentlines) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1374 a2 = randint(a1, min(currentlines, a1 + maxhunklines)) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1375 b1 = randint(0, maxb1) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1376 b2 = randint(b1, b1 + maxhunklines) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1377 currentlines += (b2 - b1) - (a2 - a1) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1378 arglist.append((rev, a1, a2, b1, b2)) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1379 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1380 def d(): |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1381 ll = linelog.linelog() |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1382 for args in arglist: |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1383 ll.replacelines(*args) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1384 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1385 timer, fm = gettimer(ui, opts) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1386 timer(d) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1387 fm.end() |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38781
diff
changeset
|
1388 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1389 @command(b'perfrevrange', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1390 def perfrevrange(ui, repo, *specs, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1391 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1392 timer, fm = gettimer(ui, opts) |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
1393 revrange = scmutil.revrange |
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
1394 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
|
1395 fm.end() |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
1396 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1397 @command(b'perfnodelookup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1398 def perfnodelookup(ui, repo, rev, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1399 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1400 timer, fm = gettimer(ui, opts) |
16309 | 1401 import mercurial.revlog |
1402 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg | |
37355
5bcd5859b505
perf: make perfmanifest and perfnodelookup work with revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37269
diff
changeset
|
1403 n = scmutil.revsingle(repo, rev).node() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1404 cl = mercurial.revlog.revlog(getsvfs(repo), b"00changelog.i") |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1405 def d(): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1406 cl.rev(n) |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
1407 clearcaches(cl) |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1408 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1409 fm.end() |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1410 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1411 @command(b'perflog', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1412 [(b'', b'rename', False, b'ask log to follow renames') |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1413 ] + formatteropts) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
1414 def perflog(ui, repo, rev=None, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1415 opts = _byteskwargs(opts) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
1416 if rev is None: |
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
1417 rev=[] |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1418 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
|
1419 ui.pushbuffer() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1420 timer(lambda: commands.log(ui, repo, rev=rev, date=b'', user=b'', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1421 copies=opts.get(b'rename'))) |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
1422 ui.popbuffer() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1423 fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
1424 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1425 @command(b'perfmoonwalk', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1426 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
|
1427 """benchmark walking the changelog backwards |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1428 |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1429 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
|
1430 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1431 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1432 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
|
1433 def moonwalk(): |
38778
a4d847cea6f8
perfmoonwalk: make work with filtered repo
Martin von Zweigbergk <martinvonz@google.com>
parents:
38695
diff
changeset
|
1434 for i in repo.changelog.revs(start=(len(repo) - 1), stop=-1): |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1435 ctx = repo[i] |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1436 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
|
1437 timer(moonwalk) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1438 fm.end() |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1439 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1440 @command(b'perftemplating', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1441 [(b'r', b'rev', [], b'revisions to run the template on'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1442 ] + formatteropts) |
38258
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
1443 def perftemplating(ui, repo, testedtemplate=None, **opts): |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
1444 """test the rendering time of a given template""" |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1445 if makelogtemplater is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1446 raise error.Abort((b"perftemplating not available with this Mercurial"), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1447 hint=b"use 4.3 or later") |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1448 |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1449 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1450 |
38255
71d59b487d0c
perftemplating: drop usage of buffer
Boris Feld <boris.feld@octobus.net>
parents:
38254
diff
changeset
|
1451 nullui = ui.copy() |
39824
db875f97a969
py3: un-byteify strings around os.system() and os.devnull in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39823
diff
changeset
|
1452 nullui.fout = open(os.devnull, r'wb') |
38255
71d59b487d0c
perftemplating: drop usage of buffer
Boris Feld <boris.feld@octobus.net>
parents:
38254
diff
changeset
|
1453 nullui.disablepager() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1454 revs = opts.get(b'rev') |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1455 if not revs: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1456 revs = [b'all()'] |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1457 revs = list(scmutil.revrange(repo, revs)) |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1458 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1459 defaulttemplate = (b'{date|shortdate} [{rev}:{node|short}]' |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1460 b' {author|person}: {desc|firstline}\n') |
38258
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
1461 if testedtemplate is None: |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
1462 testedtemplate = defaulttemplate |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38257
diff
changeset
|
1463 displayer = makelogtemplater(nullui, repo, testedtemplate) |
38254
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38253
diff
changeset
|
1464 def format(): |
38257
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1465 for r in revs: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1466 ctx = repo[r] |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1467 displayer.show(ctx) |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38256
diff
changeset
|
1468 displayer.flush(ctx) |
38254
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38253
diff
changeset
|
1469 |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1470 timer, fm = gettimer(ui, opts) |
38254
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38253
diff
changeset
|
1471 timer(format) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1472 fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
1473 |
42385
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1474 @command(b'perfhelper-mergecopies', formatteropts + |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1475 [ |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1476 (b'r', b'revs', [], b'restrict search to these revisions'), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1477 (b'', b'timing', False, b'provides extra data (costly)'), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1478 ]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1479 def perfhelpermergecopies(ui, repo, revs=[], **opts): |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1480 """find statistics about potential parameters for `perfmergecopies` |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1481 |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1482 This command find (base, p1, p2) triplet relevant for copytracing |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1483 benchmarking in the context of a merge. It reports values for some of the |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1484 parameters that impact merge copy tracing time during merge. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1485 |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1486 If `--timing` is set, rename detection is run and the associated timing |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1487 will be reported. The extra details come at the cost of slower command |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1488 execution. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1489 |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1490 Since rename detection is only run once, other factors might easily |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1491 affect the precision of the timing. However it should give a good |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1492 approximation of which revision triplets are very costly. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1493 """ |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1494 opts = _byteskwargs(opts) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1495 fm = ui.formatter(b'perf', opts) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1496 dotiming = opts[b'timing'] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1497 |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1498 output_template = [ |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1499 ("base", "%(base)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1500 ("p1", "%(p1.node)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1501 ("p2", "%(p2.node)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1502 ("p1.nb-revs", "%(p1.nbrevs)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1503 ("p1.nb-files", "%(p1.nbmissingfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1504 ("p1.renames", "%(p1.renamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1505 ("p1.time", "%(p1.time)12.3f"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1506 ("p2.nb-revs", "%(p2.nbrevs)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1507 ("p2.nb-files", "%(p2.nbmissingfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1508 ("p2.renames", "%(p2.renamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1509 ("p2.time", "%(p2.time)12.3f"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1510 ("renames", "%(nbrenamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1511 ("total.time", "%(time)12.3f"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1512 ] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1513 if not dotiming: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1514 output_template = [i for i in output_template |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1515 if not ('time' in i[0] or 'renames' in i[0])] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1516 header_names = [h for (h, v) in output_template] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1517 output = ' '.join([v for (h, v) in output_template]) + '\n' |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1518 header = ' '.join(['%12s'] * len(header_names)) + '\n' |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1519 fm.plain(header % tuple(header_names)) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1520 |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1521 if not revs: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1522 revs = ['all()'] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1523 revs = scmutil.revrange(repo, revs) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1524 |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1525 roi = repo.revs('merge() and %ld', revs) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1526 for r in roi: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1527 ctx = repo[r] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1528 p1 = ctx.p1() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1529 p2 = ctx.p2() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1530 bases = repo.changelog._commonancestorsheads(p1.rev(), p2.rev()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1531 for b in bases: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1532 b = repo[b] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1533 p1missing = copies._computeforwardmissing(b, p1) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1534 p2missing = copies._computeforwardmissing(b, p2) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1535 data = { |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1536 b'base': b.hex(), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1537 b'p1.node': p1.hex(), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1538 b'p1.nbrevs': len(repo.revs('%d::%d', b.rev(), p1.rev())), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1539 b'p1.nbmissingfiles': len(p1missing), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1540 b'p2.node': p2.hex(), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1541 b'p2.nbrevs': len(repo.revs('%d::%d', b.rev(), p2.rev())), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1542 b'p2.nbmissingfiles': len(p2missing), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1543 } |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1544 if dotiming: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1545 begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1546 mergedata = copies.mergecopies(repo, p1, p2, b) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1547 end = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1548 # not very stable timing since we did only one run |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1549 data['time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1550 # mergedata contains five dicts: "copy", "movewithdir", |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1551 # "diverge", "renamedelete" and "dirmove". |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1552 # The first 4 are about renamed file so lets count that. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1553 renames = len(mergedata[0]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1554 renames += len(mergedata[1]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1555 renames += len(mergedata[2]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1556 renames += len(mergedata[3]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1557 data['nbrenamedfiles'] = renames |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1558 begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1559 p1renames = copies.pathcopies(b, p1) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1560 end = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1561 data['p1.time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1562 begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1563 p2renames = copies.pathcopies(b, p2) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1564 data['p2.time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1565 end = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1566 data['p1.renamedfiles'] = len(p1renames) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1567 data['p2.renamedfiles'] = len(p2renames) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1568 fm.startitem() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1569 fm.data(**data) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1570 # make node pretty for the human output |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1571 out = data.copy() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1572 out['base'] = fm.hexfunc(b.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1573 out['p1.node'] = fm.hexfunc(p1.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1574 out['p2.node'] = fm.hexfunc(p2.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1575 fm.plain(output % out) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1576 |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1577 fm.end() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42384
diff
changeset
|
1578 |
40740
30d878cb102d
perf: rename `perfhelper-tracecopies` to `perfhelper-pathcopies`
Boris Feld <boris.feld@octobus.net>
parents:
40739
diff
changeset
|
1579 @command(b'perfhelper-pathcopies', formatteropts + |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1580 [ |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1581 (b'r', b'revs', [], b'restrict search to these revisions'), |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1582 (b'', b'timing', False, b'provides extra data (costly)'), |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1583 ]) |
40740
30d878cb102d
perf: rename `perfhelper-tracecopies` to `perfhelper-pathcopies`
Boris Feld <boris.feld@octobus.net>
parents:
40739
diff
changeset
|
1584 def perfhelperpathcopies(ui, repo, revs=[], **opts): |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1585 """find statistic about potential parameters for the `perftracecopies` |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1586 |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1587 This command find source-destination pair relevant for copytracing testing. |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1588 It report value for some of the parameters that impact copy tracing time. |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1589 |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1590 If `--timing` is set, rename detection is run and the associated timing |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1591 will be reported. The extra details comes at the cost of a slower command |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1592 execution. |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1593 |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1594 Since the rename detection is only run once, other factors might easily |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1595 affect the precision of the timing. However it should give a good |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1596 approximation of which revision pairs are very costly. |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1597 """ |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1598 opts = _byteskwargs(opts) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1599 fm = ui.formatter(b'perf', opts) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1600 dotiming = opts[b'timing'] |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1601 |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1602 if dotiming: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1603 header = '%12s %12s %12s %12s %12s %12s\n' |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1604 output = ("%(source)12s %(destination)12s " |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1605 "%(nbrevs)12d %(nbmissingfiles)12d " |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1606 "%(nbrenamedfiles)12d %(time)18.5f\n") |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1607 header_names = ("source", "destination", "nb-revs", "nb-files", |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1608 "nb-renames", "time") |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1609 fm.plain(header % header_names) |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1610 else: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1611 header = '%12s %12s %12s %12s\n' |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1612 output = ("%(source)12s %(destination)12s " |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1613 "%(nbrevs)12d %(nbmissingfiles)12d\n") |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1614 fm.plain(header % ("source", "destination", "nb-revs", "nb-files")) |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1615 |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1616 if not revs: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1617 revs = ['all()'] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1618 revs = scmutil.revrange(repo, revs) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1619 |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1620 roi = repo.revs('merge() and %ld', revs) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1621 for r in roi: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1622 ctx = repo[r] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1623 p1 = ctx.p1().rev() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1624 p2 = ctx.p2().rev() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1625 bases = repo.changelog._commonancestorsheads(p1, p2) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1626 for p in (p1, p2): |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1627 for b in bases: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1628 base = repo[b] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1629 parent = repo[p] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1630 missing = copies._computeforwardmissing(base, parent) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1631 if not missing: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1632 continue |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1633 data = { |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1634 b'source': base.hex(), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1635 b'destination': parent.hex(), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1636 b'nbrevs': len(repo.revs('%d::%d', b, p)), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1637 b'nbmissingfiles': len(missing), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1638 } |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1639 if dotiming: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1640 begin = util.timer() |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1641 renames = copies.pathcopies(base, parent) |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1642 end = util.timer() |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1643 # not very stable timing since we did only one run |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1644 data['time'] = end - begin |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1645 data['nbrenamedfiles'] = len(renames) |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1646 fm.startitem() |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1647 fm.data(**data) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1648 out = data.copy() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1649 out['source'] = fm.hexfunc(base.node()) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1650 out['destination'] = fm.hexfunc(parent.node()) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1651 fm.plain(output % out) |
40731
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
1652 |
40691
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1653 fm.end() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40683
diff
changeset
|
1654 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1655 @command(b'perfcca', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1656 def perfcca(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1657 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1658 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
|
1659 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
|
1660 fm.end() |
16386
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
1661 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1662 @command(b'perffncacheload', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1663 def perffncacheload(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1664 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1665 timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
1666 s = repo.store |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1667 def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1668 s.fncache._load() |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1669 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1670 fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1671 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1672 @command(b'perffncachewrite', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1673 def perffncachewrite(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1674 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1675 timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
1676 s = repo.store |
38695
2cdb82e8fb44
perffncachewrite: load fncache after lock is acquired
Boris Feld <boris.feld@octobus.net>
parents:
38694
diff
changeset
|
1677 lock = repo.lock() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1678 s.fncache._load() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1679 tr = repo.transaction(b'perffncachewrite') |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1680 tr.addbackup(b'fncache') |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1681 def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1682 s.fncache._dirty = True |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
1683 s.fncache.write(tr) |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1684 timer(d) |
30069
98b9846a131e
perf: release lock after transaction in perffncachewrite
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30018
diff
changeset
|
1685 tr.close() |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
1686 lock.release() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1687 fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
1688 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1689 @command(b'perffncacheencode', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1690 def perffncacheencode(ui, repo, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1691 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1692 timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
1693 s = repo.store |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
1694 s.fncache._load() |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
1695 def d(): |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
1696 for p in s.fncache.entries: |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
1697 s.encode(p) |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
1698 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1699 fm.end() |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
1700 |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1701 def _bdiffworker(q, blocks, xdiff, ready, done): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1702 while not done.is_set(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1703 pair = q.get() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1704 while pair is not None: |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1705 if xdiff: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1706 mdiff.bdiff.xdiffblocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1707 elif blocks: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1708 mdiff.bdiff.blocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1709 else: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1710 mdiff.textdiff(*pair) |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1711 q.task_done() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1712 pair = q.get() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1713 q.task_done() # for the None one |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1714 with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1715 ready.wait() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1716 |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1717 def _manifestrevision(repo, mnode): |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1718 ml = repo.manifestlog |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1719 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1720 if util.safehasattr(ml, b'getstorage'): |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1721 store = ml.getstorage(b'') |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1722 else: |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1723 store = ml._revlog |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1724 |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1725 return store.revision(mnode) |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1726 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1727 @command(b'perfbdiff', revlogopts + formatteropts + [ |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1728 (b'', b'count', 1, b'number of revisions to test (when using --startrev)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1729 (b'', b'alldata', False, b'test bdiffs for all associated revisions'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1730 (b'', b'threads', 0, b'number of thread to use (disable with 0)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1731 (b'', b'blocks', False, b'test computing diffs into blocks'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1732 (b'', b'xdiff', False, b'use xdiff algorithm'), |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1733 ], |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1734 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1735 b'-c|-m|FILE REV') |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1736 def perfbdiff(ui, repo, file_, rev=None, count=None, threads=0, **opts): |
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
1737 """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
|
1738 |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
1739 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
|
1740 |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
1741 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
|
1742 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
|
1743 |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1744 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
|
1745 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
|
1746 and filelogs). |
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
1747 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1748 opts = _byteskwargs(opts) |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1749 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1750 if opts[b'xdiff'] and not opts[b'blocks']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1751 raise error.CommandError(b'perfbdiff', b'--xdiff requires --blocks') |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1752 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1753 if opts[b'alldata']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1754 opts[b'changelog'] = True |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1755 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1756 if opts.get(b'changelog') or opts.get(b'manifest'): |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1757 file_, rev = None, file_ |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1758 elif rev is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1759 raise error.CommandError(b'perfbdiff', b'invalid arguments') |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1760 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1761 blocks = opts[b'blocks'] |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1762 xdiff = opts[b'xdiff'] |
30335
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30307
diff
changeset
|
1763 textpairs = [] |
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30307
diff
changeset
|
1764 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1765 r = cmdutil.openrevlog(repo, b'perfbdiff', file_, opts) |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1766 |
30336
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30335
diff
changeset
|
1767 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
|
1768 for rev in range(startrev, min(startrev + count, len(r) - 1)): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1769 if opts[b'alldata']: |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1770 # 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
|
1771 ctx = repo[rev] |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1772 mtext = _manifestrevision(repo, ctx.manifestnode()) |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1773 for pctx in ctx.parents(): |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1774 pman = _manifestrevision(repo, pctx.manifestnode()) |
30337
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1775 textpairs.append((pman, mtext)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1776 |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1777 # 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
|
1778 man = ctx.manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1779 pman = ctx.p1().manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1780 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
|
1781 fctx = repo.file(filename) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1782 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
|
1783 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
|
1784 textpairs.append((f1, f2)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1785 else: |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1786 dp = r.deltaparent(rev) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30336
diff
changeset
|
1787 textpairs.append((r.revision(dp), r.revision(rev))) |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1788 |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1789 withthreads = threads > 0 |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1790 if not withthreads: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1791 def d(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1792 for pair in textpairs: |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1793 if xdiff: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1794 mdiff.bdiff.xdiffblocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1795 elif blocks: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1796 mdiff.bdiff.blocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1797 else: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1798 mdiff.textdiff(*pair) |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1799 else: |
37844
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
1800 q = queue() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
1801 for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1802 q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1803 ready = threading.Condition() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1804 done = threading.Event() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
1805 for i in _xrange(threads): |
36766
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1806 threading.Thread(target=_bdiffworker, |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36360
diff
changeset
|
1807 args=(q, blocks, xdiff, ready, done)).start() |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1808 q.join() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1809 def d(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1810 for pair in textpairs: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1811 q.put(pair) |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
1812 for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1813 q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1814 with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1815 ready.notify_all() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1816 q.join() |
30307
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1817 timer, fm = gettimer(ui, opts) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1818 timer(d) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1819 fm.end() |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
1820 |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1821 if withthreads: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1822 done.set() |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
1823 for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1824 q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1825 with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1826 ready.notify_all() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35116
diff
changeset
|
1827 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1828 @command(b'perfunidiff', revlogopts + formatteropts + [ |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1829 (b'', b'count', 1, b'number of revisions to test (when using --startrev)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1830 (b'', b'alldata', False, b'test unidiffs for all associated revisions'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1831 ], b'-c|-m|FILE REV') |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1832 def perfunidiff(ui, repo, file_, rev=None, count=None, **opts): |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1833 """benchmark a unified diff between revisions |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1834 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1835 This doesn't include any copy tracing - it's just a unified diff |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1836 of the texts. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1837 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1838 By default, benchmark a diff between its delta parent and itself. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1839 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1840 With ``--count``, benchmark diffs between delta parents and self for N |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1841 revisions starting at the specified revision. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1842 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1843 With ``--alldata``, assume the requested revision is a changeset and |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1844 measure diffs for all changes related to that changeset (manifest |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1845 and filelogs). |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1846 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1847 opts = _byteskwargs(opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1848 if opts[b'alldata']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1849 opts[b'changelog'] = True |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1850 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1851 if opts.get(b'changelog') or opts.get(b'manifest'): |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1852 file_, rev = None, file_ |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1853 elif rev is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1854 raise error.CommandError(b'perfunidiff', b'invalid arguments') |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1855 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1856 textpairs = [] |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1857 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1858 r = cmdutil.openrevlog(repo, b'perfunidiff', file_, opts) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1859 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1860 startrev = r.rev(r.lookup(rev)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1861 for rev in range(startrev, min(startrev + count, len(r) - 1)): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1862 if opts[b'alldata']: |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1863 # Load revisions associated with changeset. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1864 ctx = repo[rev] |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1865 mtext = _manifestrevision(repo, ctx.manifestnode()) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1866 for pctx in ctx.parents(): |
39319
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39318
diff
changeset
|
1867 pman = _manifestrevision(repo, pctx.manifestnode()) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1868 textpairs.append((pman, mtext)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1869 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1870 # Load filelog revisions by iterating manifest delta. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1871 man = ctx.manifest() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1872 pman = ctx.p1().manifest() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1873 for filename, change in pman.diff(man).items(): |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1874 fctx = repo.file(filename) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1875 f1 = fctx.revision(change[0][0] or -1) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1876 f2 = fctx.revision(change[1][0] or -1) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1877 textpairs.append((f1, f2)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1878 else: |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1879 dp = r.deltaparent(rev) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1880 textpairs.append((r.revision(dp), r.revision(rev))) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1881 |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1882 def d(): |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1883 for left, right in textpairs: |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1884 # The date strings don't matter, so we pass empty strings. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1885 headerlines, hunks = mdiff.unidiff( |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1886 left, b'', right, b'', b'left', b'right', binary=False) |
35861
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1887 # consume iterators in roughly the way patch.py does |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1888 b'\n'.join(headerlines) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1889 b''.join(sum((list(hlines) for hrange, hlines in hunks), [])) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1890 timer, fm = gettimer(ui, opts) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1891 timer(d) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1892 fm.end() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
1893 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1894 @command(b'perfdiffwd', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1895 def perfdiffwd(ui, repo, **opts): |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1896 """Profile diff of working directory changes""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1897 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1898 timer, fm = gettimer(ui, opts) |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1899 options = { |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
1900 'w': 'ignore_all_space', |
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
1901 'b': 'ignore_space_change', |
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
1902 'B': 'ignore_blank_lines', |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1903 } |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1904 |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
1905 for diffopt in ('', 'w', 'b', 'B', 'wB'): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1906 opts = dict((options[c], b'1') for c in diffopt) |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1907 def d(): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1908 ui.pushbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1909 commands.diff(ui, repo, **opts) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1910 ui.popbuffer() |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
1911 diffopt = diffopt.encode('ascii') |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1912 title = b'diffopts: %s' % (diffopt and (b'-' + diffopt) or b'none') |
40679
20d2fd6036ed
perf: explicitly pass title as a keyword argument in `perfdiffwd`
Boris Feld <boris.feld@octobus.net>
parents:
40558
diff
changeset
|
1913 timer(d, title=title) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1914 fm.end() |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
1915 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1916 @command(b'perfrevlogindex', revlogopts + formatteropts, |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1917 b'-c|-m|FILE') |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1918 def perfrevlogindex(ui, repo, file_=None, **opts): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1919 """Benchmark operations against a revlog index. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1920 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1921 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
|
1922 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
|
1923 index data. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1924 """ |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1925 |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1926 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
1927 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1928 rl = cmdutil.openrevlog(repo, b'perfrevlogindex', file_, opts) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1929 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1930 opener = getattr(rl, 'opener') # trick linter |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1931 indexfile = rl.indexfile |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1932 data = opener.read(indexfile) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1933 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1934 header = struct.unpack(b'>I', data[0:4])[0] |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1935 version = header & 0xFFFF |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1936 if version == 1: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1937 revlogio = revlog.revlogio() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1938 inline = header & (1 << 16) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1939 else: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
1940 raise error.Abort((b'unsupported revlog version: %d') % version) |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1941 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1942 rllen = len(rl) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1943 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1944 node0 = rl.node(0) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1945 node25 = rl.node(rllen // 4) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1946 node50 = rl.node(rllen // 2) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1947 node75 = rl.node(rllen // 4 * 3) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1948 node100 = rl.node(rllen - 1) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1949 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1950 allrevs = range(rllen) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1951 allrevsrev = list(reversed(allrevs)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1952 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
|
1953 allnodesrev = list(reversed(allnodes)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1954 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1955 def constructor(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1956 revlog.revlog(opener, indexfile) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1957 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1958 def read(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1959 with opener(indexfile) as fh: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1960 fh.read() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1961 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1962 def parseindex(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1963 revlogio.parseindex(data, inline) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1964 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1965 def getentry(revornode): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1966 index = revlogio.parseindex(data, inline)[0] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1967 index[revornode] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1968 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1969 def getentries(revs, count=1): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1970 index = revlogio.parseindex(data, inline)[0] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1971 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1972 for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1973 for rev in revs: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1974 index[rev] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1975 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1976 def resolvenode(node): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1977 nodemap = revlogio.parseindex(data, inline)[1] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1978 # This only works for the C code. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1979 if nodemap is None: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1980 return |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1981 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1982 try: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1983 nodemap[node] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1984 except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1985 pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1986 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1987 def resolvenodes(nodes, count=1): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1988 nodemap = revlogio.parseindex(data, inline)[1] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1989 if nodemap is None: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1990 return |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1991 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1992 for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1993 for node in nodes: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1994 try: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1995 nodemap[node] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1996 except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1997 pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1998 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
1999 benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2000 (constructor, b'revlog constructor'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2001 (read, b'read'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2002 (parseindex, b'create index object'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2003 (lambda: getentry(0), b'retrieve index entry for rev 0'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2004 (lambda: resolvenode(b'a' * 20), b'look up missing node'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2005 (lambda: resolvenode(node0), b'look up node at rev 0'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2006 (lambda: resolvenode(node25), b'look up node at 1/4 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2007 (lambda: resolvenode(node50), b'look up node at 1/2 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2008 (lambda: resolvenode(node75), b'look up node at 3/4 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2009 (lambda: resolvenode(node100), b'look up node at tip'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2010 # 2x variation is to measure caching impact. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2011 (lambda: resolvenodes(allnodes), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2012 b'look up all nodes (forward)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2013 (lambda: resolvenodes(allnodes, 2), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2014 b'look up all nodes 2x (forward)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2015 (lambda: resolvenodes(allnodesrev), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2016 b'look up all nodes (reverse)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2017 (lambda: resolvenodes(allnodesrev, 2), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2018 b'look up all nodes 2x (reverse)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2019 (lambda: getentries(allrevs), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2020 b'retrieve all index entries (forward)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2021 (lambda: getentries(allrevs, 2), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2022 b'retrieve all index entries 2x (forward)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2023 (lambda: getentries(allrevsrev), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2024 b'retrieve all index entries (reverse)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2025 (lambda: getentries(allrevsrev, 2), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2026 b'retrieve all index entries 2x (reverse)'), |
32532
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2027 ] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2028 |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2029 for fn, title in benches: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2030 timer, fm = gettimer(ui, opts) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2031 timer(fn, title=title) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2032 fm.end() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32531
diff
changeset
|
2033 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2034 @command(b'perfrevlogrevisions', revlogopts + formatteropts + |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2035 [(b'd', b'dist', 100, b'distance between the revisions'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2036 (b's', b'startrev', 0, b'revision to start reading at'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2037 (b'', b'reverse', False, b'read in reverse')], |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2038 b'-c|-m|FILE') |
32531
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32467
diff
changeset
|
2039 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
|
2040 **opts): |
27492
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
2041 """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
|
2042 |
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
2043 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
|
2044 the specified revlog. |
27493
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
2045 |
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
2046 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
|
2047 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2048 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2049 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2050 rl = cmdutil.openrevlog(repo, b'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
|
2051 rllen = getlen(ui)(rl) |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2052 |
40143
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
2053 if startrev < 0: |
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
2054 startrev = rllen + startrev |
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
2055 |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
2056 def d(): |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
2057 rl.clearcaches() |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2058 |
32224
6b582f9b6e5e
perf: don't clobber startrev variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32202
diff
changeset
|
2059 beginrev = startrev |
32232
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32231
diff
changeset
|
2060 endrev = rllen |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2061 dist = opts[b'dist'] |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2062 |
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2063 if reverse: |
40537
cbd251d479bb
perf: fix perfrevlogrevisions --reverse
Boris Feld <boris.feld@octobus.net>
parents:
40531
diff
changeset
|
2064 beginrev, endrev = endrev - 1, beginrev - 1 |
30017
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2065 dist = -1 * dist |
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2066 |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2067 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
|
2068 # 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
|
2069 n = rl.node(x) |
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32232
diff
changeset
|
2070 rl.revision(n) |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
2071 |
32225
c68c400d0a2d
perf: move gettimer() call
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32224
diff
changeset
|
2072 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
|
2073 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2074 fm.end() |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
2075 |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2076 @command(b'perfrevlogwrite', revlogopts + formatteropts + |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2077 [(b's', b'startrev', 1000, b'revision to start writing at'), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2078 (b'', b'stoprev', -1, b'last revision to write'), |
42460
e4c85e23c9ff
perf: fix perfrevlogwrite --count documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42392
diff
changeset
|
2079 (b'', b'count', 3, b'number of passes to perform'), |
40551
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2080 (b'', b'details', False, b'print timing for every revisions tested'), |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2081 (b'', b'source', b'full', b'the kind of data feed in the revlog'), |
40558
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40557
diff
changeset
|
2082 (b'', b'lazydeltabase', True, b'try the provided delta first'), |
40977
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
2083 (b'', b'clear-caches', True, b'clear revlog cache between calls'), |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2084 ], |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2085 b'-c|-m|FILE') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2086 def perfrevlogwrite(ui, repo, file_=None, startrev=1000, stoprev=-1, **opts): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2087 """Benchmark writing a series of revisions to a revlog. |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2088 |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2089 Possible source values are: |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2090 * `full`: add from a full text (default). |
40554
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
2091 * `parent-1`: add from a delta to the first parent |
40555
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2092 * `parent-2`: add from a delta to the second parent if it exists |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2093 (use a delta from the first parent otherwise) |
40556
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2094 * `parent-smallest`: add from the smallest delta (either p1 or p2) |
40557
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
2095 * `storage`: add from the existing precomputed deltas |
42461
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2096 |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2097 Note: This performance command measures performance in a custom way. As a |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2098 result some of the global configuration of the 'perf' command does not |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2099 apply to it: |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2100 |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2101 * ``pre-run``: disabled |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2102 |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2103 * ``profile-benchmark``: disabled |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2104 |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42460
diff
changeset
|
2105 * ``run-limits``: disabled use --count instead |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2106 """ |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2107 opts = _byteskwargs(opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2108 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2109 rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2110 rllen = getlen(ui)(rl) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2111 if startrev < 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2112 startrev = rllen + startrev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2113 if stoprev < 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2114 stoprev = rllen + stoprev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2115 |
40558
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40557
diff
changeset
|
2116 lazydeltabase = opts['lazydeltabase'] |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2117 source = opts['source'] |
41002
e88ced97151d
perfrevlogwrite: fix a typo in the option name
Boris Feld <boris.feld@octobus.net>
parents:
40977
diff
changeset
|
2118 clearcaches = opts['clear_caches'] |
40557
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
2119 validsource = (b'full', b'parent-1', b'parent-2', b'parent-smallest', |
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
2120 b'storage') |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2121 if source not in validsource: |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2122 raise error.Abort('invalid source type: %s' % source) |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2123 |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2124 ### actually gather results |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2125 count = opts['count'] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2126 if count <= 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2127 raise error.Abort('invalide run count: %d' % count) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2128 allresults = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2129 for c in range(count): |
40558
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40557
diff
changeset
|
2130 timing = _timeonewrite(ui, rl, source, startrev, stoprev, c + 1, |
40977
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
2131 lazydeltabase=lazydeltabase, |
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
2132 clearcaches=clearcaches) |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2133 allresults.append(timing) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2134 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2135 ### consolidate the results in a single list |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2136 results = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2137 for idx, (rev, t) in enumerate(allresults[0]): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2138 ts = [t] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2139 for other in allresults[1:]: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2140 orev, ot = other[idx] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2141 assert orev == rev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2142 ts.append(ot) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2143 results.append((rev, ts)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2144 resultcount = len(results) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2145 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2146 ### Compute and display relevant statistics |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2147 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2148 # get a formatter |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2149 fm = ui.formatter(b'perf', opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2150 displayall = ui.configbool(b"perf", b"all-timing", False) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2151 |
40551
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2152 # print individual details if requested |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2153 if opts['details']: |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2154 for idx, item in enumerate(results, 1): |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2155 rev, data = item |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2156 title = 'revisions #%d of %d, rev %d' % (idx, resultcount, rev) |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2157 formatone(fm, data, title=title, displayall=displayall) |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40550
diff
changeset
|
2158 |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2159 # sorts results by median time |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2160 results.sort(key=lambda x: sorted(x[1])[len(x[1]) // 2]) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2161 # list of (name, index) to display) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2162 relevants = [ |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2163 ("min", 0), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2164 ("10%", resultcount * 10 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2165 ("25%", resultcount * 25 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2166 ("50%", resultcount * 70 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2167 ("75%", resultcount * 75 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2168 ("90%", resultcount * 90 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2169 ("95%", resultcount * 95 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2170 ("99%", resultcount * 99 // 100), |
40956
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40948
diff
changeset
|
2171 ("99.9%", resultcount * 999 // 1000), |
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40948
diff
changeset
|
2172 ("99.99%", resultcount * 9999 // 10000), |
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40948
diff
changeset
|
2173 ("99.999%", resultcount * 99999 // 100000), |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2174 ("max", -1), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2175 ] |
40552
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
2176 if not ui.quiet: |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
2177 for name, idx in relevants: |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
2178 data = results[idx] |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
2179 title = '%s of %d, rev %d' % (name, resultcount, data[0]) |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40551
diff
changeset
|
2180 formatone(fm, data[1], title=title, displayall=displayall) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2181 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2182 # XXX summing that many float will not be very precise, we ignore this fact |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2183 # for now |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2184 totaltime = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2185 for item in allresults: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2186 totaltime.append((sum(x[1][0] for x in item), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2187 sum(x[1][1] for x in item), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2188 sum(x[1][2] for x in item),) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2189 ) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2190 formatone(fm, totaltime, title="total time (%d revs)" % resultcount, |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2191 displayall=displayall) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2192 fm.end() |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2193 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2194 class _faketr(object): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2195 def add(s, x, y, z=None): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2196 return None |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2197 |
40558
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40557
diff
changeset
|
2198 def _timeonewrite(ui, orig, source, startrev, stoprev, runidx=None, |
40977
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
2199 lazydeltabase=True, clearcaches=True): |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2200 timings = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2201 tr = _faketr() |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2202 with _temprevlog(ui, orig, startrev) as dest: |
40558
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40557
diff
changeset
|
2203 dest._lazydeltabase = lazydeltabase |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2204 revs = list(orig.revs(startrev, stoprev)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2205 total = len(revs) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2206 topic = 'adding' |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2207 if runidx is not None: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2208 topic += ' (run #%d)' % runidx |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2209 # Support both old and new progress API |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2210 if util.safehasattr(ui, 'makeprogress'): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2211 progress = ui.makeprogress(topic, unit='revs', total=total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2212 def updateprogress(pos): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2213 progress.update(pos) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2214 def completeprogress(): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2215 progress.complete() |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2216 else: |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2217 def updateprogress(pos): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2218 ui.progress(topic, pos, unit='revs', total=total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2219 def completeprogress(): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2220 ui.progress(topic, None, unit='revs', total=total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2221 |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2222 for idx, rev in enumerate(revs): |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2223 updateprogress(idx) |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2224 addargs, addkwargs = _getrevisionseed(orig, rev, tr, source) |
40977
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
2225 if clearcaches: |
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
2226 dest.index.clearcaches() |
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40956
diff
changeset
|
2227 dest.clearcaches() |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2228 with timeone() as r: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2229 dest.addrawrevision(*addargs, **addkwargs) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2230 timings.append((rev, r[0])) |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2231 updateprogress(total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41002
diff
changeset
|
2232 completeprogress() |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2233 return timings |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2234 |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2235 def _getrevisionseed(orig, rev, tr, source): |
40555
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2236 from mercurial.node import nullid |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2237 |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2238 linkrev = orig.linkrev(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2239 node = orig.node(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2240 p1, p2 = orig.parents(node) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2241 flags = orig.flags(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2242 cachedelta = None |
40553
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2243 text = None |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2244 |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2245 if source == b'full': |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40552
diff
changeset
|
2246 text = orig.revision(rev) |
40554
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
2247 elif source == b'parent-1': |
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
2248 baserev = orig.rev(p1) |
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40553
diff
changeset
|
2249 cachedelta = (baserev, orig.revdiff(p1, rev)) |
40555
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2250 elif source == b'parent-2': |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2251 parent = p2 |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2252 if p2 == nullid: |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2253 parent = p1 |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2254 baserev = orig.rev(parent) |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40554
diff
changeset
|
2255 cachedelta = (baserev, orig.revdiff(parent, rev)) |
40556
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2256 elif source == b'parent-smallest': |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2257 p1diff = orig.revdiff(p1, rev) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2258 parent = p1 |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2259 diff = p1diff |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2260 if p2 != nullid: |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2261 p2diff = orig.revdiff(p2, rev) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2262 if len(p1diff) > len(p2diff): |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2263 parent = p2 |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2264 diff = p2diff |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2265 baserev = orig.rev(parent) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40555
diff
changeset
|
2266 cachedelta = (baserev, diff) |
40557
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
2267 elif source == b'storage': |
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
2268 baserev = orig.deltaparent(rev) |
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40556
diff
changeset
|
2269 cachedelta = (baserev, orig.revdiff(orig.node(baserev), rev)) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2270 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2271 return ((text, tr, linkrev, p1, p2), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2272 {'node': node, 'flags': flags, 'cachedelta': cachedelta}) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2273 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2274 @contextlib.contextmanager |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2275 def _temprevlog(ui, orig, truncaterev): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2276 from mercurial import vfs as vfsmod |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2277 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2278 if orig._inline: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2279 raise error.Abort('not supporting inline revlog (yet)') |
42462
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
2280 revlogkwargs = {} |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
2281 k = 'upperboundcomp' |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
2282 if util.safehasattr(orig, k): |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
2283 revlogkwargs[k] = getattr(orig, k) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2284 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2285 origindexpath = orig.opener.join(orig.indexfile) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2286 origdatapath = orig.opener.join(orig.datafile) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2287 indexname = 'revlog.i' |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2288 dataname = 'revlog.d' |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2289 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2290 tmpdir = tempfile.mkdtemp(prefix='tmp-hgperf-') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2291 try: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2292 # copy the data file in a temporary directory |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2293 ui.debug('copying data in %s\n' % tmpdir) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2294 destindexpath = os.path.join(tmpdir, 'revlog.i') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2295 destdatapath = os.path.join(tmpdir, 'revlog.d') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2296 shutil.copyfile(origindexpath, destindexpath) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2297 shutil.copyfile(origdatapath, destdatapath) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2298 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2299 # remove the data we want to add again |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2300 ui.debug('truncating data to be rewritten\n') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2301 with open(destindexpath, 'ab') as index: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2302 index.seek(0) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2303 index.truncate(truncaterev * orig._io.size) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2304 with open(destdatapath, 'ab') as data: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2305 data.seek(0) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2306 data.truncate(orig.start(truncaterev)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2307 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2308 # instantiate a new revlog from the temporary copy |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2309 ui.debug('truncating adding to be rewritten\n') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2310 vfs = vfsmod.vfs(tmpdir) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2311 vfs.options = getattr(orig.opener, 'options', None) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2312 |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2313 dest = revlog.revlog(vfs, |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2314 indexfile=indexname, |
42462
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42461
diff
changeset
|
2315 datafile=dataname, **revlogkwargs) |
40550
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2316 if dest._inline: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2317 raise error.Abort('not supporting inline revlog (yet)') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2318 # make sure internals are initialized |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2319 dest.revision(len(dest) - 1) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2320 yield dest |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2321 del dest, vfs |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2322 finally: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2323 shutil.rmtree(tmpdir, True) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40537
diff
changeset
|
2324 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2325 @command(b'perfrevlogchunks', revlogopts + formatteropts + |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2326 [(b'e', b'engines', b'', b'compression engines to use'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2327 (b's', b'startrev', 0, b'revision to start at')], |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2328 b'-c|-m|FILE') |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2329 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
|
2330 """Benchmark operations on revlog chunks. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2331 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2332 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
|
2333 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
|
2334 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
|
2335 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2336 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
|
2337 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
|
2338 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
|
2339 see ``perfrevlogrevisions`` and ``perfrevlogrevision``. |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2340 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2341 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2342 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2343 rl = cmdutil.openrevlog(repo, b'perfrevlogchunks', file_, opts) |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2344 |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2345 # _chunkraw was renamed to _getsegmentforrevs. |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2346 try: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2347 segmentforrevs = rl._getsegmentforrevs |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2348 except AttributeError: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2349 segmentforrevs = rl._chunkraw |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2350 |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2351 # Verify engines argument. |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2352 if engines: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2353 engines = set(e.strip() for e in engines.split(b',')) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2354 for engine in engines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2355 try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2356 util.compressionengines[engine] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2357 except KeyError: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2358 raise error.Abort(b'unknown compression engine: %s' % engine) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2359 else: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2360 engines = [] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2361 for e in util.compengines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2362 engine = util.compengines[e] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2363 try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2364 if engine.available(): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2365 engine.revlogcompressor().compress(b'dummy') |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2366 engines.append(e) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2367 except NotImplementedError: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2368 pass |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2369 |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2370 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
|
2371 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2372 def rlfh(rl): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2373 if rl._inline: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2374 return getsvfs(repo)(rl.indexfile) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2375 else: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2376 return getsvfs(repo)(rl.datafile) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2377 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2378 def doread(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2379 rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2380 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
|
2381 segmentforrevs(rev, rev) |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2382 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2383 def doreadcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2384 rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2385 fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2386 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
|
2387 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
|
2388 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2389 def doreadbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2390 rl.clearcaches() |
32228
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32225
diff
changeset
|
2391 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
|
2392 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2393 def doreadbatchcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2394 rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2395 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
|
2396 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
|
2397 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2398 def dochunk(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2399 rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2400 fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2401 for rev in revs: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2402 rl._chunk(rev, df=fh) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2403 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2404 chunks = [None] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2405 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2406 def dochunkbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2407 rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2408 fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2409 # 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
|
2410 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
|
2411 |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2412 def docompress(compressor): |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2413 rl.clearcaches() |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2414 |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2415 try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2416 # Swap in the requested compression engine. |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2417 oldcompressor = rl._compressor |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2418 rl._compressor = compressor |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2419 for chunk in chunks[0]: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2420 rl.compress(chunk) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2421 finally: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2422 rl._compressor = oldcompressor |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2423 |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2424 benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2425 (lambda: doread(), b'read'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2426 (lambda: doreadcachedfh(), b'read w/ reused fd'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2427 (lambda: doreadbatch(), b'read batch'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2428 (lambda: doreadbatchcachedfh(), b'read batch w/ reused fd'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2429 (lambda: dochunk(), b'chunk'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2430 (lambda: dochunkbatch(), b'chunk batch'), |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2431 ] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2432 |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2433 for engine in sorted(engines): |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2434 compressor = util.compengines[engine].revlogcompressor() |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2435 benches.append((functools.partial(docompress, compressor), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2436 b'compress w/ %s' % engine)) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
2437 |
30451
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2438 for fn, title in benches: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2439 timer, fm = gettimer(ui, opts) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2440 timer(fn, title=title) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2441 fm.end() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30426
diff
changeset
|
2442 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2443 @command(b'perfrevlogrevision', revlogopts + formatteropts + |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2444 [(b'', b'cache', False, b'use caches instead of clearing')], |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2445 b'-c|-m|FILE REV') |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2446 def perfrevlogrevision(ui, repo, file_, rev=None, cache=None, **opts): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2447 """Benchmark obtaining a revlog revision. |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2448 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2449 Obtaining a revlog revision consists of roughly the following steps: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2450 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2451 1. Compute the delta chain |
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2452 2. Slice the delta chain if applicable |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2453 3. Obtain the raw chunks for that delta chain |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2454 4. Decompress each raw chunk |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2455 5. Apply binary patches to obtain fulltext |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2456 6. Verify hash of fulltext |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2457 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2458 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
|
2459 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2460 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2461 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2462 if opts.get(b'changelog') or opts.get(b'manifest'): |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2463 file_, rev = None, file_ |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2464 elif rev is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2465 raise error.CommandError(b'perfrevlogrevision', b'invalid arguments') |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2466 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2467 r = cmdutil.openrevlog(repo, b'perfrevlogrevision', file_, opts) |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2468 |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2469 # _chunkraw was renamed to _getsegmentforrevs. |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2470 try: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2471 segmentforrevs = r._getsegmentforrevs |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2472 except AttributeError: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2473 segmentforrevs = r._chunkraw |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32228
diff
changeset
|
2474 |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2475 node = r.lookup(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2476 rev = r.rev(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2477 |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2478 def getrawchunks(data, chain): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2479 start = r.start |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2480 length = r.length |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2481 inline = r._inline |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2482 iosize = r._io.size |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2483 buffer = util.buffer |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2484 |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2485 chunks = [] |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2486 ladd = chunks.append |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2487 for idx, item in enumerate(chain): |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2488 offset = start(item[0]) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2489 bits = data[idx] |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2490 for rev in item: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2491 chunkstart = start(rev) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2492 if inline: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2493 chunkstart += (rev + 1) * iosize |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2494 chunklength = length(rev) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2495 ladd(buffer(bits, chunkstart - offset, chunklength)) |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2496 |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2497 return chunks |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2498 |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2499 def dodeltachain(rev): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2500 if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2501 r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2502 r._deltachain(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2503 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2504 def doread(chain): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2505 if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2506 r.clearcaches() |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2507 for item in slicedchain: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2508 segmentforrevs(item[0], item[-1]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2509 |
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2510 def doslice(r, chain, size): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2511 for s in slicechunk(r, chain, targetsize=size): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2512 pass |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2513 |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2514 def dorawchunks(data, chain): |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2515 if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2516 r.clearcaches() |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2517 getrawchunks(data, chain) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2518 |
30882
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2519 def dodecompress(chunks): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2520 decomp = r.decompress |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2521 for chunk in chunks: |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
2522 decomp(chunk) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2523 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2524 def dopatch(text, bins): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2525 if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2526 r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2527 mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2528 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2529 def dohash(text): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2530 if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2531 r.clearcaches() |
30584
be5b2098a817
revlog: merge hash checking subfunctions
Remi Chaintron <remi@fb.com>
parents:
30451
diff
changeset
|
2532 r.checkhash(text, node, rev=rev) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2533 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2534 def dorevision(): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2535 if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2536 r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2537 r.revision(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2538 |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2539 try: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2540 from mercurial.revlogutils.deltas import slicechunk |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2541 except ImportError: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2542 slicechunk = getattr(revlog, '_slicechunk', None) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2543 |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2544 size = r.length(rev) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2545 chain = r._deltachain(rev)[0] |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2546 if not getattr(r, '_withsparseread', False): |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2547 slicedchain = (chain,) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2548 else: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2549 slicedchain = tuple(slicechunk(r, chain, targetsize=size)) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2550 data = [segmentforrevs(seg[0], seg[-1])[1] for seg in slicedchain] |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2551 rawchunks = getrawchunks(data, slicedchain) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2552 bins = r._chunks(chain) |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
2553 text = bytes(bins[0]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2554 bins = bins[1:] |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2555 text = mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2556 |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2557 benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2558 (lambda: dorevision(), b'full'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2559 (lambda: dodeltachain(rev), b'deltachain'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2560 (lambda: doread(chain), b'read'), |
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2561 ] |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2562 |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2563 if getattr(r, '_withsparseread', False): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2564 slicing = (lambda: doslice(r, chain, size), b'slice-sparse-chain') |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2565 benches.append(slicing) |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2566 |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2567 benches.extend([ |
40530
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40529
diff
changeset
|
2568 (lambda: dorawchunks(data, slicedchain), b'rawchunks'), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2569 (lambda: dodecompress(rawchunks), b'decompress'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2570 (lambda: dopatch(text, bins), b'patch'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2571 (lambda: dohash(text), b'hash'), |
40531
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40530
diff
changeset
|
2572 ]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2573 |
40529
cf3bef7f162b
perf: use the same timer for all section of perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40349
diff
changeset
|
2574 timer, fm = gettimer(ui, opts) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2575 for fn, title in benches: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2576 timer(fn, title=title) |
40529
cf3bef7f162b
perf: use the same timer for all section of perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40349
diff
changeset
|
2577 fm.end() |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
2578 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2579 @command(b'perfrevset', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2580 [(b'C', b'clear', False, b'clear volatile cache between each call.'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2581 (b'', b'contexts', False, b'obtain changectx for each revision')] |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2582 + formatteropts, b"REVSET") |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
2583 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
|
2584 """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
|
2585 |
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18304
diff
changeset
|
2586 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
|
2587 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
|
2588 and obsolete related cache.""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2589 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2590 |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2591 timer, fm = gettimer(ui, opts) |
18062
1471f5e83686
perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents:
18033
diff
changeset
|
2592 def d(): |
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
2593 if clear: |
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
2594 repo.invalidatevolatilesets() |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
2595 if contexts: |
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
2596 for ctx in repo.set(expr): pass |
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
2597 else: |
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
2598 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
|
2599 timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2600 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
|
2601 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2602 @command(b'perfvolatilesets', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2603 [(b'', b'clear-obsstore', False, b'drop obsstore between each call.'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2604 ] + formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2605 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
|
2606 """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
|
2607 |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
2608 Volatile set computes element related to filtering and obsolescence.""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2609 opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2610 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
|
2611 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
|
2612 |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
2613 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
|
2614 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
|
2615 repo.invalidatevolatilesets() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2616 if opts[b'clear_obsstore']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2617 clearfilecache(repo, b'obsstore') |
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
2618 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
|
2619 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
|
2620 |
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
2621 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
|
2622 if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
2623 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
|
2624 |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
2625 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
|
2626 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
|
2627 |
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
2628 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
|
2629 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
|
2630 repo.invalidatevolatilesets() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2631 if opts[b'clear_obsstore']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2632 clearfilecache(repo, b'obsstore') |
20205
d67a7758da6d
perf: fix perfvolatilesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20178
diff
changeset
|
2633 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
|
2634 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
|
2635 |
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
2636 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
|
2637 if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
2638 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
|
2639 |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
2640 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
|
2641 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
|
2642 fm.end() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2643 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2644 @command(b'perfbranchmap', |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2645 [(b'f', b'full', False, |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2646 b'Includes build time of subset'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2647 (b'', b'clear-revbranch', False, |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2648 b'purge the revbranch cache between computation'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2649 ] + formatteropts) |
36360
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
2650 def perfbranchmap(ui, repo, *filternames, **opts): |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2651 """benchmark the update of a branchmap |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2652 |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2653 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
|
2654 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2655 opts = _byteskwargs(opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2656 full = opts.get(b"full", False) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2657 clear_revbranch = opts.get(b"clear_revbranch", False) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2658 timer, fm = gettimer(ui, opts) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2659 def getbranchmap(filtername): |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2660 """generate a benchmark function for the filtername""" |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2661 if filtername is None: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2662 view = repo |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2663 else: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2664 view = repo.filtered(filtername) |
41615
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
2665 if util.safehasattr(view._branchcaches, '_per_filter'): |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
2666 filtered = view._branchcaches._per_filter |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
2667 else: |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
2668 # older versions |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
2669 filtered = view._branchcaches |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2670 def d(): |
32710
326c0e2c1a1d
perfbranchmap: add an option to purge the revbranch cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32532
diff
changeset
|
2671 if clear_revbranch: |
326c0e2c1a1d
perfbranchmap: add an option to purge the revbranch cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32532
diff
changeset
|
2672 repo.revbranchcache()._clear() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2673 if full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2674 view._branchcaches.clear() |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2675 else: |
41615
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41565
diff
changeset
|
2676 filtered.pop(filtername, None) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2677 view.branchmap() |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2678 return d |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2679 # 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
|
2680 possiblefilters = set(repoview.filtertable) |
36360
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
2681 if filternames: |
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
2682 possiblefilters &= set(filternames) |
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
|
2683 subsettable = getbranchmapsubsettable() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2684 allfilters = [] |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2685 while possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2686 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
|
2687 subset = subsettable.get(name) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2688 if subset not in possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2689 break |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2690 else: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2691 assert False, b'subset cycle %s!' % possiblefilters |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2692 allfilters.append(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2693 possiblefilters.remove(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2694 |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2695 # warm the cache |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2696 if not full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2697 for name in allfilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2698 repo.filtered(name).branchmap() |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2699 if not filternames or b'unfiltered' in filternames: |
36360
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
2700 # add unfiltered |
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36359
diff
changeset
|
2701 allfilters.append(None) |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
2702 |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2703 if util.safehasattr(branchmap.branchcache, 'fromfile'): |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2704 branchcacheread = safeattrsetter(branchmap.branchcache, b'fromfile') |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2705 branchcacheread.set(classmethod(lambda *args: None)) |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2706 else: |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2707 # older versions |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2708 branchcacheread = safeattrsetter(branchmap, b'read') |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2709 branchcacheread.set(lambda *args: None) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2710 branchcachewrite = safeattrsetter(branchmap.branchcache, b'write') |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2711 branchcachewrite.set(lambda *args: None) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2712 try: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2713 for name in allfilters: |
36359
df3f7f00a3fc
perfbranchmap: display 'unfiltered' for unfiltered performance
Boris Feld <boris.feld@octobus.net>
parents:
36178
diff
changeset
|
2714 printname = name |
df3f7f00a3fc
perfbranchmap: display 'unfiltered' for unfiltered performance
Boris Feld <boris.feld@octobus.net>
parents:
36178
diff
changeset
|
2715 if name is None: |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2716 printname = b'unfiltered' |
36359
df3f7f00a3fc
perfbranchmap: display 'unfiltered' for unfiltered performance
Boris Feld <boris.feld@octobus.net>
parents:
36178
diff
changeset
|
2717 timer(getbranchmap(name), title=str(printname)) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
2718 finally: |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
2719 branchcacheread.restore() |
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
2720 branchcachewrite.restore() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2721 fm.end() |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
2722 |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2723 @command(b'perfbranchmapupdate', [ |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2724 (b'', b'base', [], b'subset of revision to start from'), |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2725 (b'', b'target', [], b'subset of revision to end with'), |
40772
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2726 (b'', b'clear-caches', False, b'clear cache between each runs') |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2727 ] + formatteropts) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2728 def perfbranchmapupdate(ui, repo, base=(), target=(), **opts): |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2729 """benchmark branchmap update from for <base> revs to <target> revs |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2730 |
40772
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2731 If `--clear-caches` is passed, the following items will be reset before |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2732 each update: |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2733 * the changelog instance and associated indexes |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2734 * the rev-branch-cache instance |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2735 |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2736 Examples: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2737 |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2738 # update for the one last revision |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2739 $ hg perfbranchmapupdate --base 'not tip' --target 'tip' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2740 |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2741 $ update for change coming with a new branch |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2742 $ hg perfbranchmapupdate --base 'stable' --target 'default' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2743 """ |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2744 from mercurial import branchmap |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2745 from mercurial import repoview |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2746 opts = _byteskwargs(opts) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2747 timer, fm = gettimer(ui, opts) |
40772
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2748 clearcaches = opts[b'clear_caches'] |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2749 unfi = repo.unfiltered() |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2750 x = [None] # used to pass data between closure |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2751 |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2752 # we use a `list` here to avoid possible side effect from smartset |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2753 baserevs = list(scmutil.revrange(repo, base)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2754 targetrevs = list(scmutil.revrange(repo, target)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2755 if not baserevs: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2756 raise error.Abort(b'no revisions selected for --base') |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2757 if not targetrevs: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2758 raise error.Abort(b'no revisions selected for --target') |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2759 |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2760 # make sure the target branchmap also contains the one in the base |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2761 targetrevs = list(set(baserevs) | set(targetrevs)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2762 targetrevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2763 |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2764 cl = repo.changelog |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2765 allbaserevs = list(cl.ancestors(baserevs, inclusive=True)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2766 allbaserevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2767 alltargetrevs = frozenset(cl.ancestors(targetrevs, inclusive=True)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2768 |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2769 newrevs = list(alltargetrevs.difference(allbaserevs)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2770 newrevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2771 |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2772 allrevs = frozenset(unfi.changelog.revs()) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2773 basefilterrevs = frozenset(allrevs.difference(allbaserevs)) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2774 targetfilterrevs = frozenset(allrevs.difference(alltargetrevs)) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2775 |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2776 def basefilter(repo, visibilityexceptions=None): |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2777 return basefilterrevs |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2778 |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2779 def targetfilter(repo, visibilityexceptions=None): |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2780 return targetfilterrevs |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2781 |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2782 msg = b'benchmark of branchmap with %d revisions with %d new ones\n' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2783 ui.status(msg % (len(allbaserevs), len(newrevs))) |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2784 if targetfilterrevs: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2785 msg = b'(%d revisions still filtered)\n' |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2786 ui.status(msg % len(targetfilterrevs)) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2787 |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2788 try: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2789 repoview.filtertable[b'__perf_branchmap_update_base'] = basefilter |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2790 repoview.filtertable[b'__perf_branchmap_update_target'] = targetfilter |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2791 |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2792 baserepo = repo.filtered(b'__perf_branchmap_update_base') |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2793 targetrepo = repo.filtered(b'__perf_branchmap_update_target') |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2794 |
40771
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2795 # try to find an existing branchmap to reuse |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2796 subsettable = getbranchmapsubsettable() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2797 candidatefilter = subsettable.get(None) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2798 while candidatefilter is not None: |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2799 candidatebm = repo.filtered(candidatefilter).branchmap() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2800 if candidatebm.validfor(baserepo): |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2801 filtered = repoview.filterrevs(repo, candidatefilter) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2802 missing = [r for r in allbaserevs if r in filtered] |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2803 base = candidatebm.copy() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2804 base.update(baserepo, missing) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2805 break |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2806 candidatefilter = subsettable.get(candidatefilter) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2807 else: |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2808 # no suitable subset where found |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2809 base = branchmap.branchcache() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40770
diff
changeset
|
2810 base.update(baserepo, allbaserevs) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2811 |
40769
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
2812 def setup(): |
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
2813 x[0] = base.copy() |
40772
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2814 if clearcaches: |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2815 unfi._revbranchcache = None |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40771
diff
changeset
|
2816 clearchangelog(repo) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2817 |
40769
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
2818 def bench(): |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2819 x[0].update(targetrepo, newrevs) |
40769
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
2820 |
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
2821 timer(bench, setup=setup) |
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40768
diff
changeset
|
2822 fm.end() |
40770
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2823 finally: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2824 repoview.filtertable.pop(b'__perf_branchmap_update_base', None) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40769
diff
changeset
|
2825 repoview.filtertable.pop(b'__perf_branchmap_update_target', None) |
40768
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40750
diff
changeset
|
2826 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2827 @command(b'perfbranchmapload', [ |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2828 (b'f', b'filter', b'', b'Specify repoview filter'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2829 (b'', b'list', False, b'List brachmap filter caches'), |
40702
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
2830 (b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
2831 |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2832 ] + formatteropts) |
40699
94d76ddac40a
perf: update function name to match `perfbranchmapload` command
Boris Feld <boris.feld@octobus.net>
parents:
40698
diff
changeset
|
2833 def perfbranchmapload(ui, repo, filter=b'', list=False, **opts): |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2834 """benchmark reading the branchmap""" |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2835 opts = _byteskwargs(opts) |
40702
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
2836 clearrevlogs = opts[b'clear_revlogs'] |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2837 |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2838 if list: |
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2839 for name, kind, st in repo.cachevfs.readdir(stat=True): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2840 if name.startswith(b'branch2'): |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2841 filtername = name.partition(b'-')[2] or b'unfiltered' |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2842 ui.status(b'%s - %s\n' |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2843 % (filtername, util.bytecount(st.st_size))) |
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2844 return |
40720
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2845 if not filter: |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2846 filter = None |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2847 subsettable = getbranchmapsubsettable() |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2848 if filter is None: |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2849 repo = repo.unfiltered() |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2850 else: |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2851 repo = repoview.repoview(repo, filter) |
40719
578646b1e2b6
perf: prewarm the branchmap in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40713
diff
changeset
|
2852 |
578646b1e2b6
perf: prewarm the branchmap in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40713
diff
changeset
|
2853 repo.branchmap() # make sure we have a relevant, up to date branchmap |
578646b1e2b6
perf: prewarm the branchmap in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40713
diff
changeset
|
2854 |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2855 try: |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2856 fromfile = branchmap.branchcache.fromfile |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2857 except AttributeError: |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2858 # older versions |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2859 fromfile = branchmap.read |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2860 |
40720
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2861 currentfilter = filter |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2862 # try once without timer, the filter may not be cached |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2863 while fromfile(repo) is None: |
40720
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2864 currentfilter = subsettable.get(currentfilter) |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2865 if currentfilter is None: |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2866 raise error.Abort(b'No branchmap cached for %s repo' |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2867 % (filter or b'unfiltered')) |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
2868 repo = repo.filtered(currentfilter) |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2869 timer, fm = gettimer(ui, opts) |
40702
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
2870 def setup(): |
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
2871 if clearrevlogs: |
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
2872 clearchangelog(repo) |
40700
30f443d34a7d
perf: use an explicit function in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40699
diff
changeset
|
2873 def bench(): |
41565
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41470
diff
changeset
|
2874 fromfile(repo) |
40702
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40701
diff
changeset
|
2875 timer(bench, setup=setup) |
39114
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2876 fm.end() |
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
38977
diff
changeset
|
2877 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2878 @command(b'perfloadmarkers') |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
2879 def perfloadmarkers(ui, repo): |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
2880 """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
|
2881 |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
2882 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
|
2883 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
|
2884 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
|
2885 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
|
2886 fm.end() |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2887 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2888 @command(b'perflrucachedict', formatteropts + |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2889 [(b'', b'costlimit', 0, b'maximum total cost of items in cache'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2890 (b'', b'mincost', 0, b'smallest cost of items in cache'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2891 (b'', b'maxcost', 100, b'maximum cost of items in cache'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2892 (b'', b'size', 4, b'size of cache'), |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2893 (b'', b'gets', 10000, b'number of key lookups'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2894 (b'', b'sets', 10000, b'number of key sets'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2895 (b'', b'mixed', 10000, b'number of mixed mode operations'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2896 (b'', b'mixedgetfreq', 50, b'frequency of get vs set ops in mixed mode')], |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2897 norepo=True) |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2898 def perflrucache(ui, mincost=0, maxcost=100, costlimit=0, size=4, |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2899 gets=10000, sets=10000, mixed=10000, mixedgetfreq=50, **opts): |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2900 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
2901 |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2902 def doinit(): |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2903 for i in _xrange(10000): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2904 util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2905 |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2906 costrange = list(range(mincost, maxcost + 1)) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2907 |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2908 values = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2909 for i in _xrange(size): |
39823
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
2910 values.append(random.randint(0, _maxint)) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2911 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2912 # 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
|
2913 # eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2914 getseq = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2915 for i in _xrange(gets): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2916 getseq.append(random.choice(values)) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2917 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2918 def dogets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2919 d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2920 for v in values: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2921 d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2922 for key in getseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2923 value = d[key] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2924 value # silence pyflakes warning |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2925 |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2926 def dogetscost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2927 d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2928 for i, v in enumerate(values): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2929 d.insert(v, v, cost=costs[i]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2930 for key in getseq: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2931 try: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2932 value = d[key] |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2933 value # silence pyflakes warning |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2934 except KeyError: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2935 pass |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2936 |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2937 # Set mode tests insertion speed with cache eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2938 setseq = [] |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2939 costs = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2940 for i in _xrange(sets): |
39823
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39822
diff
changeset
|
2941 setseq.append(random.randint(0, _maxint)) |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2942 costs.append(random.choice(costrange)) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2943 |
39567
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
2944 def doinserts(): |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
2945 d = util.lrucachedict(size) |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
2946 for v in setseq: |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
2947 d.insert(v, v) |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39362
diff
changeset
|
2948 |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2949 def doinsertscost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2950 d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2951 for i, v in enumerate(setseq): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2952 d.insert(v, v, cost=costs[i]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2953 |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2954 def dosets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2955 d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2956 for v in setseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2957 d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2958 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2959 # Mixed mode randomly performs gets and sets with eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2960 mixedops = [] |
39822
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39821
diff
changeset
|
2961 for i in _xrange(mixed): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2962 r = random.randint(0, 100) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2963 if r < mixedgetfreq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2964 op = 0 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2965 else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2966 op = 1 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2967 |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2968 mixedops.append((op, |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2969 random.randint(0, size * 2), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2970 random.choice(costrange))) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2971 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2972 def domixed(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2973 d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2974 |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2975 for op, v, cost in mixedops: |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2976 if op == 0: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2977 try: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2978 d[v] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2979 except KeyError: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2980 pass |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2981 else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2982 d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2983 |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2984 def domixedcost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2985 d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2986 |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2987 for op, v, cost in mixedops: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2988 if op == 0: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2989 try: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2990 d[v] |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2991 except KeyError: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2992 pass |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2993 else: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2994 d.insert(v, v, cost=cost) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
2995 |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2996 benches = [ |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
2997 (doinit, b'init'), |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2998 ] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
2999 |
39568
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3000 if costlimit: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3001 benches.extend([ |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3002 (dogetscost, b'gets w/ cost limit'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3003 (doinsertscost, b'inserts w/ cost limit'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3004 (domixedcost, b'mixed w/ cost limit'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3005 ]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3006 else: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3007 benches.extend([ |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3008 (dogets, b'gets'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3009 (doinserts, b'inserts'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3010 (dosets, b'sets'), |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3011 (domixed, b'mixed') |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3012 ]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39567
diff
changeset
|
3013 |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3014 for fn, title in benches: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3015 timer, fm = gettimer(ui, opts) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3016 timer(fn, title=title) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3017 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
|
3018 |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3019 @command(b'perfwrite', formatteropts) |
30977
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3020 def perfwrite(ui, repo, **opts): |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3021 """microbenchmark ui.write |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3022 """ |
39825
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3023 opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39824
diff
changeset
|
3024 |
30977
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3025 timer, fm = gettimer(ui, opts) |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3026 def write(): |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3027 for i in range(100000): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3028 ui.write((b'Testing write performance\n')) |
30977
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3029 timer(write) |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3030 fm.end() |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30975
diff
changeset
|
3031 |
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
|
3032 def uisetup(ui): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3033 if (util.safehasattr(cmdutil, b'openrevlog') and |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3034 not util.safehasattr(commands, b'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
|
3035 # 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
|
3036 # 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
|
3037 # 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
|
3038 # 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
|
3039 # 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
|
3040 def openrevlog(orig, repo, cmd, file_, opts): |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3041 if opts.get(b'dir') and not util.safehasattr(repo, b'dirlog'): |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3042 raise error.Abort(b"This version doesn't support --dir option", |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3043 hint=b"use 3.5 or later") |
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
|
3044 return orig(repo, cmd, file_, opts) |
39362
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39319
diff
changeset
|
3045 extensions.wrapfunction(cmdutil, b'openrevlog', openrevlog) |
40925
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3046 |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3047 @command(b'perfprogress', formatteropts + [ |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3048 (b'', b'topic', b'topic', b'topic for progress messages'), |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3049 (b'c', b'total', 1000000, b'total value we are progressing to'), |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3050 ], norepo=True) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3051 def perfprogress(ui, topic=None, total=None, **opts): |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3052 """printing of progress bars""" |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3053 opts = _byteskwargs(opts) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3054 |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3055 timer, fm = gettimer(ui, opts) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3056 |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3057 def doprogress(): |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3058 with ui.makeprogress(topic, total=total) as progress: |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3059 for i in pycompat.xrange(total): |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3060 progress.increment() |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3061 |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3062 timer(doprogress) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40784
diff
changeset
|
3063 fm.end() |