author | Joerg Sonnenberger <joerg@bec.de> |
Wed, 13 Jan 2021 16:14:58 +0100 | |
changeset 46793 | 6266d19556ad |
parent 46733 | 66fb04552122 |
child 46973 | 92029a43debb |
permissions | -rw-r--r-- |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 |
# perf.py - performance test routines |
42015
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
2 |
'''helper extension to measure performance |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
3 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
4 |
Configurations |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
5 |
============== |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
6 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
7 |
``perf`` |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
8 |
-------- |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
9 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
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:
41663
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:
41663
diff
changeset
|
13 |
(default: off). |
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
diff
changeset
|
14 |
|
dbca2e5563c3
perf: document config options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41663
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:
41663
diff
changeset
|
17 |
|
42381
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 |
|
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
21 |
``profile-benchmark`` |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
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:
42381
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:
42381
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:
41663
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:
41663
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 |
31406
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30997
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 |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
63 |
import shutil |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
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 |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
66 |
import tempfile |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
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 ( |
30020
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
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, |
40954
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
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, |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
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: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
87 |
from mercurial import branchmap # since 2.5 (or bcee63733aad) |
29567
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: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
91 |
from mercurial import obsolete # since 2.3 (or ad0d6c2b3279) |
29567
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: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
95 |
from mercurial import registrar # since 3.7 (or 37d50250b696) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
96 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
97 |
dir(registrar) # forcibly load it |
32376
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
98 |
except ImportError: |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
99 |
registrar = None |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
100 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
101 |
from mercurial import repoview # since 2.5 (or 3a6ddacb7198) |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
102 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
103 |
pass |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
104 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
105 |
from mercurial.utils import repoviewutil # since 5.0 |
42138
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
106 |
except ImportError: |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
107 |
repoviewutil = None |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
108 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
109 |
from mercurial import scmutil # since 1.9 (or 8b252e826c68) |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
110 |
except ImportError: |
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
111 |
pass |
40954
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
112 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
113 |
from mercurial import setdiscovery # since 1.9 (or cb98fed52495) |
40954
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
114 |
except ImportError: |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
115 |
pass |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
116 |
|
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
117 |
try: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
118 |
from mercurial import profiling |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
119 |
except ImportError: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
120 |
profiling = None |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
121 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
122 |
|
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
123 |
def identity(a): |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
124 |
return a |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
125 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
126 |
|
36216
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35990
diff
changeset
|
127 |
try: |
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35990
diff
changeset
|
128 |
from mercurial import pycompat |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
129 |
|
36216
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35990
diff
changeset
|
130 |
getargspec = pycompat.getargspec # added to module after 4.5 |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
131 |
_byteskwargs = pycompat.byteskwargs # since 4.1 (or fbc3f73dc802) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
132 |
_sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
133 |
_bytestr = pycompat.bytestr # since 4.2 (or b70407bd84d5) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
134 |
_xrange = pycompat.xrange # since 4.8 (or 7eba8f83129b) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
135 |
fsencode = pycompat.fsencode # since 3.9 (or f4a5e0e86a7e) |
39828
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39827
diff
changeset
|
136 |
if pycompat.ispy3: |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39827
diff
changeset
|
137 |
_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:
39827
diff
changeset
|
138 |
else: |
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39827
diff
changeset
|
139 |
_maxint = sys.maxint |
42799
c8d3af9c7e65
perf: handle NameError for `pycompat.foo` when pycompat wasn't imported
Martin von Zweigbergk <martinvonz@google.com>
parents:
42776
diff
changeset
|
140 |
except (NameError, ImportError, AttributeError): |
36216
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35990
diff
changeset
|
141 |
import inspect |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
142 |
|
36216
646002338365
py3: introduce and use pycompat.getargspec
Augie Fackler <augie@google.com>
parents:
35990
diff
changeset
|
143 |
getargspec = inspect.getargspec |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
144 |
_byteskwargs = identity |
42801
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42800
diff
changeset
|
145 |
_bytestr = str |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
146 |
fsencode = identity # no py3 support |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
147 |
_maxint = sys.maxint # no py3 support |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
148 |
_sysstr = lambda x: x # no py3 support |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
149 |
_xrange = xrange |
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
150 |
|
37890
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
151 |
try: |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
152 |
# 4.7+ |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
153 |
queue = pycompat.queue.Queue |
42799
c8d3af9c7e65
perf: handle NameError for `pycompat.foo` when pycompat wasn't imported
Martin von Zweigbergk <martinvonz@google.com>
parents:
42776
diff
changeset
|
154 |
except (NameError, AttributeError, ImportError): |
37890
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
155 |
# <4.7. |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
156 |
try: |
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
157 |
queue = pycompat.queue |
42799
c8d3af9c7e65
perf: handle NameError for `pycompat.foo` when pycompat wasn't imported
Martin von Zweigbergk <martinvonz@google.com>
parents:
42776
diff
changeset
|
158 |
except (NameError, AttributeError, ImportError): |
42800
777a9df5a1ef
perf: don't try to call `util.queue` on Mercurial version before it existed
Martin von Zweigbergk <martinvonz@google.com>
parents:
42799
diff
changeset
|
159 |
import Queue as queue |
37890
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
160 |
|
38269
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
161 |
try: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
162 |
from mercurial import logcmdutil |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
163 |
|
38269
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
164 |
makelogtemplater = logcmdutil.maketemplater |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
165 |
except (AttributeError, ImportError): |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
166 |
try: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
167 |
makelogtemplater = cmdutil.makelogtemplater |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
168 |
except (AttributeError, ImportError): |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
169 |
makelogtemplater = None |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
170 |
|
29567
7e2b389418da
perf: import newer modules separately for earlier Mercurial
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29497
diff
changeset
|
171 |
# 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
|
172 |
# 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
|
173 |
# 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
|
174 |
_undefined = object() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
175 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
176 |
|
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
|
177 |
def safehasattr(thing, attr): |
39826
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39779
diff
changeset
|
178 |
return getattr(thing, _sysstr(attr), _undefined) is not _undefined |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
179 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
180 |
|
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
|
181 |
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
|
182 |
|
29496
7299370cf304
perf: avoid using formatteropts for Mercurial earlier than 3.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29495
diff
changeset
|
183 |
# for "historical portability": |
31823
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
184 |
# 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:
31483
diff
changeset
|
185 |
# since ae5d60bb70c9 |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
186 |
if safehasattr(time, 'perf_counter'): |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
187 |
util.timer = time.perf_counter |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
188 |
elif os.name == b'nt': |
31823
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
189 |
util.timer = time.clock |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
190 |
else: |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
191 |
util.timer = time.time |
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
192 |
|
f6d77af84ef3
perf: add historical portability for util.timer
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
31483
diff
changeset
|
193 |
# 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
|
194 |
# 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
|
195 |
# 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
|
196 |
# 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
|
197 |
# available since 2.2 (or ae5f92e154d3) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
198 |
formatteropts = getattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
199 |
cmdutil, "formatteropts", getattr(commands, "formatteropts", []) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
200 |
) |
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
|
201 |
|
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
|
202 |
# 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
|
203 |
# 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
|
204 |
# 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
|
205 |
# 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
|
206 |
# since 1.9 (or a79fea6b3e77). |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
207 |
revlogopts = getattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
208 |
cmdutil, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
209 |
"debugrevlogopts", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
210 |
getattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
211 |
commands, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
212 |
"debugrevlogopts", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
213 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
214 |
(b'c', b'changelog', False, b'open changelog'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
215 |
(b'm', b'manifest', False, b'open manifest'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
216 |
(b'', b'dir', False, b'open directory manifest'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
217 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
218 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
219 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
220 |
|
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
221 |
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
|
222 |
|
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 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
|
225 |
# 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
|
226 |
def parsealiases(cmd): |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40214
diff
changeset
|
227 |
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
|
228 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
229 |
|
32376
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
230 |
if safehasattr(registrar, 'command'): |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
231 |
command = registrar.command(cmdtable) |
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32337
diff
changeset
|
232 |
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
|
233 |
command = cmdutil.command(cmdtable) |
45635
7d0e54056586
py3: use native string when comparing with a function's argspec
Raphaël Gomès <rgomes@octobus.net>
parents:
45016
diff
changeset
|
234 |
if '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
|
235 |
# 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
|
236 |
# 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
|
237 |
# 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
|
238 |
_command = command |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
239 |
|
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
240 |
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
|
241 |
if norepo: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
242 |
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
|
243 |
return _command(name, list(options), synopsis) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
244 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
245 |
|
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
246 |
else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
247 |
# 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
|
248 |
# 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
|
249 |
# 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
|
250 |
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
|
251 |
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
|
252 |
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
|
253 |
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
|
254 |
else: |
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
255 |
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
|
256 |
if norepo: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
257 |
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
|
258 |
return func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
259 |
|
29497
ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29496
diff
changeset
|
260 |
return decorator |
18237
4132dc9bd5c4
perftest: migrate to new style command declaration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18236
diff
changeset
|
261 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
262 |
|
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34350
diff
changeset
|
263 |
try: |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
264 |
import mercurial.registrar |
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
265 |
import mercurial.configitems |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
266 |
|
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34350
diff
changeset
|
267 |
configtable = {} |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
268 |
configitem = mercurial.registrar.configitem(configtable) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
269 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
270 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
271 |
b'presleep', |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
272 |
default=mercurial.configitems.dynamicdefault, |
42776
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
273 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
274 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
275 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
276 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
277 |
b'stub', |
42776
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
278 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
279 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
280 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
281 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
282 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
283 |
b'parentscount', |
42776
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
284 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
285 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
286 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
287 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
288 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
289 |
b'all-timing', |
42776
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
290 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
291 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
292 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
293 |
configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
294 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
295 |
b'pre-run', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
296 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
297 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
298 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
299 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
300 |
b'profile-benchmark', |
42776
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
301 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
302 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
303 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
304 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
305 |
b'run-limits', |
42776
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
306 |
default=mercurial.configitems.dynamicdefault, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
307 |
experimental=True, |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
308 |
) |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
309 |
except (ImportError, AttributeError): |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
310 |
pass |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
311 |
except TypeError: |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
312 |
# compatibility fix for a11fd395e83f |
9f2189b6bf2a
config: add experimental argument to the config registrar
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42478
diff
changeset
|
313 |
# hg version: 5.2 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
314 |
configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
315 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
316 |
b'presleep', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
317 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
318 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
319 |
configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
320 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
321 |
b'stub', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
322 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
323 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
324 |
configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
325 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
326 |
b'parentscount', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
327 |
default=mercurial.configitems.dynamicdefault, |
34749
acdc574cb8d7
contrib-perf: update the config registration
Boris Feld <boris.feld@octobus.net>
parents:
34678
diff
changeset
|
328 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
329 |
configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
330 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
331 |
b'all-timing', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
332 |
default=mercurial.configitems.dynamicdefault, |
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34350
diff
changeset
|
333 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
334 |
configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
335 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
336 |
b'pre-run', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
337 |
default=mercurial.configitems.dynamicdefault, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
338 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
339 |
configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
340 |
b'perf', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
341 |
b'profile-benchmark', |
34750
caf6c446cbe3
contrib-perf: register the 'parentscount' config item
Boris Feld <boris.feld@octobus.net>
parents:
34749
diff
changeset
|
342 |
default=mercurial.configitems.dynamicdefault, |
caf6c446cbe3
contrib-perf: register the 'parentscount' config item
Boris Feld <boris.feld@octobus.net>
parents:
34749
diff
changeset
|
343 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
344 |
configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
345 |
b'perf', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
346 |
b'run-limits', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
347 |
default=mercurial.configitems.dynamicdefault, |
42381
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
348 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
349 |
|
34494
bbb5687e5140
configitems: register the 'perf.stub' config
Boris Feld <boris.feld@octobus.net>
parents:
34350
diff
changeset
|
350 |
|
27307 | 351 |
def getlen(ui): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
352 |
if ui.configbool(b"perf", b"stub", False): |
27307 | 353 |
return lambda x: 1 |
354 |
return len |
|
355 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
356 |
|
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
357 |
class noop(object): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
358 |
"""dummy context manager""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
359 |
|
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
360 |
def __enter__(self): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
361 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
362 |
|
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
363 |
def __exit__(self, *args): |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
364 |
pass |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
365 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
366 |
|
42386
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
367 |
NOOPCTX = noop() |
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
368 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
369 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
370 |
def gettimer(ui, opts=None): |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
371 |
"""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
|
372 |
|
27303
57bd9c5431a5
perf: improve grammar of gettimer comment
timeless <timeless@mozdev.org>
parents:
27286
diff
changeset
|
373 |
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
|
374 |
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
|
375 |
|
316ad725a1dd
perf: add a configurable sleep on startup
Matt Mackall <mpm@selenic.com>
parents:
23537
diff
changeset
|
376 |
# 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
|
377 |
# experimental config: perf.presleep |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
378 |
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
|
379 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
380 |
if opts is None: |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
381 |
opts = {} |
30415
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30380
diff
changeset
|
382 |
# 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:
30380
diff
changeset
|
383 |
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:
30380
diff
changeset
|
384 |
ui = ui.copy() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
385 |
uifout = safeattrsetter(ui, b'fout', ignoremissing=True) |
30415
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30380
diff
changeset
|
386 |
if uifout: |
e77e8876886f
perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
30380
diff
changeset
|
387 |
# 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:
30380
diff
changeset
|
388 |
# 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:
30380
diff
changeset
|
389 |
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
|
390 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
391 |
# 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
|
392 |
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
|
393 |
if uiformatter: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
394 |
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
|
395 |
else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
396 |
# 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
|
397 |
# 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
|
398 |
# 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
|
399 |
from mercurial import node |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
400 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
401 |
class defaultformatter(object): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
402 |
"""Minimized composition of baseformatter and plainformatter""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
403 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
404 |
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
|
405 |
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
|
406 |
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
|
407 |
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
|
408 |
else: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
409 |
self.hexfunc = node.short |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
410 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
411 |
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
|
412 |
return False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
413 |
|
31483
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31406
diff
changeset
|
414 |
__bool__ = __nonzero__ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
415 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
416 |
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
|
417 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
418 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
419 |
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
|
420 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
421 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
422 |
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
|
423 |
self._ui.write(deftext % fielddata, **opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
424 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
425 |
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
|
426 |
if cond: |
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
427 |
self._ui.write(deftext % fielddata, **opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
428 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
429 |
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
|
430 |
self._ui.write(text, **opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
431 |
|
30147
423bf74d2e5b
perf: define formatter locally for Mercurial earlier than 2.2
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
432 |
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
|
433 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
434 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
435 |
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
|
436 |
|
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
437 |
# 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
|
438 |
# experimental config: perf.stub |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
439 |
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
|
440 |
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
|
441 |
|
55101513ed94
perf: add a 'perf.all-timing' option to display more than best time
Boris Feld <boris.feld@octobus.net>
parents:
38693
diff
changeset
|
442 |
# experimental config: perf.all-timing |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
443 |
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
|
444 |
|
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
445 |
# 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
|
446 |
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
|
447 |
limits = [] |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
448 |
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
|
449 |
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
|
450 |
if len(parts) < 2: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
451 |
ui.warn((b'malformatted run limit entry, missing "-": %s\n' % item)) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
452 |
continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
453 |
try: |
42801
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42800
diff
changeset
|
454 |
time_limit = float(_sysstr(parts[0])) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
455 |
except ValueError as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
456 |
ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
457 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
458 |
b'malformatted run limit entry, %s: %s\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
459 |
% (_bytestr(e), item) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
460 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
461 |
) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
462 |
continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
463 |
try: |
42801
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42800
diff
changeset
|
464 |
run_limit = int(_sysstr(parts[1])) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
465 |
except ValueError as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
466 |
ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
467 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
468 |
b'malformatted run limit entry, %s: %s\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
469 |
% (_bytestr(e), item) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
470 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
471 |
) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
472 |
continue |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
473 |
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
|
474 |
if not limits: |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
475 |
limits = DEFAULTLIMITS |
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
476 |
|
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
477 |
profiler = None |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
478 |
if profiling is not None: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
479 |
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:
42381
diff
changeset
|
480 |
profiler = profiling.profile(ui) |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
481 |
|
42381
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
482 |
prerun = getint(ui, b"perf", b"pre-run", 0) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
483 |
t = functools.partial( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
484 |
_timer, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
485 |
fm, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
486 |
displayall=displayall, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
487 |
limits=limits, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
488 |
prerun=prerun, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
489 |
profiler=profiler, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
490 |
) |
42019
5a1e621b8186
perf: introduce a `perf.run-limits` options
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42018
diff
changeset
|
491 |
return t, fm |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
492 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
493 |
|
40719
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40718
diff
changeset
|
494 |
def stub_timer(fm, func, setup=None, title=None): |
40760
0adc2c0a0792
perf: run 'setup' function during stub run
Boris Feld <boris.feld@octobus.net>
parents:
40759
diff
changeset
|
495 |
if setup is not None: |
0adc2c0a0792
perf: run 'setup' function during stub run
Boris Feld <boris.feld@octobus.net>
parents:
40759
diff
changeset
|
496 |
setup() |
27304
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
497 |
func() |
a6fd79495770
perf: offer perf.stub to only run one loop
timeless <timeless@mozdev.org>
parents:
27303
diff
changeset
|
498 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
499 |
|
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
500 |
@contextlib.contextmanager |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
501 |
def timeone(): |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
502 |
r = [] |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
yield r |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
506 |
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
|
507 |
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
|
508 |
a, b = ostart, ostop |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
509 |
r.append((cstop - cstart, b[0] - a[0], b[1] - a[1])) |
40144
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
510 |
|
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
511 |
|
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
512 |
# 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
|
513 |
DEFAULTLIMITS = ( |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
514 |
(3.0, 100), |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
515 |
(10.0, 3), |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
516 |
) |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
517 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
518 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
519 |
def _timer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
520 |
fm, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
521 |
func, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
522 |
setup=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
523 |
title=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
524 |
displayall=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
525 |
limits=DEFAULTLIMITS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
526 |
prerun=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
527 |
profiler=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
528 |
): |
31406
8f5ed8fa39f8
perf: perform a garbage collection before each iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30997
diff
changeset
|
529 |
gc.collect() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
530 |
results = [] |
30995
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30914
diff
changeset
|
531 |
begin = util.timer() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
532 |
count = 0 |
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
533 |
if profiler is None: |
42386
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
534 |
profiler = NOOPCTX |
42392
c2d10506725c
py3: use range() instead of xrange()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42386
diff
changeset
|
535 |
for i in range(prerun): |
42381
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
536 |
if setup is not None: |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
537 |
setup() |
563cd9a72682
perf: add a `pre-run` option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42138
diff
changeset
|
538 |
func() |
42017
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
539 |
keepgoing = True |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
540 |
while keepgoing: |
40719
9d88ae5c635b
perf: add a `setup` argument to run code outside of the timed section
Boris Feld <boris.feld@octobus.net>
parents:
40718
diff
changeset
|
541 |
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:
40718
diff
changeset
|
542 |
setup() |
42382
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
543 |
with profiler: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
544 |
with timeone() as item: |
3293086ff663
perf: add an option to profile the benchmark section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42381
diff
changeset
|
545 |
r = func() |
42386
a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42382
diff
changeset
|
546 |
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
|
547 |
count += 1 |
acf560bc9b56
perf: extract the timing of a section in a context manager
Boris Feld <boris.feld@octobus.net>
parents:
40143
diff
changeset
|
548 |
results.append(item[0]) |
30995
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30914
diff
changeset
|
549 |
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
|
550 |
# 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
|
551 |
elapsed = cstop - begin |
42018
0e6422942c84
perf: pass limits as a function argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42017
diff
changeset
|
552 |
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
|
553 |
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
|
554 |
keepgoing = False |
87066cf5ec0f
perf: more flexible implementation for checking stop conditions
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42016
diff
changeset
|
555 |
break |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
556 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
557 |
formatone(fm, results, title=title, result=r, displayall=displayall) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
558 |
|
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
559 |
|
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
560 |
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
|
561 |
|
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
562 |
count = len(timings) |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
563 |
|
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
564 |
fm.startitem() |
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
565 |
|
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
566 |
if title: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
567 |
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
|
568 |
if result: |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
569 |
fm.write(b'result', b'! result: %s\n', result) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
570 |
|
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
|
571 |
def display(role, entry): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
572 |
prefix = b'' |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
573 |
if role != b'best': |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
574 |
prefix = b'%s.' % role |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
575 |
fm.plain(b'!') |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
576 |
fm.write(prefix + b'wall', b' wall %f', entry[0]) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
577 |
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:
39346
diff
changeset
|
578 |
fm.write(prefix + b'user', b' user %f', entry[1]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
579 |
fm.write(prefix + b'sys', b' sys %f', entry[2]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
580 |
fm.write(prefix + b'count', b' (%s of %%d)' % role, count) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
581 |
fm.plain(b'\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
582 |
|
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
583 |
timings.sort() |
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
584 |
min_val = timings[0] |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
585 |
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
|
586 |
if displayall: |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
587 |
max_val = timings[-1] |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
588 |
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
|
589 |
avg = tuple([sum(x) / count for x in zip(*timings)]) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
590 |
display(b'avg', avg) |
40145
21261fc0fb2b
perf: extract result formatting in its own function
Boris Feld <boris.feld@octobus.net>
parents:
40144
diff
changeset
|
591 |
median = timings[len(timings) // 2] |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
592 |
display(b'median', median) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
593 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
594 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
595 |
# utilities for historical portability |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
596 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
597 |
|
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
|
598 |
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
|
599 |
# 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
|
600 |
# 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
|
601 |
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
|
602 |
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
|
603 |
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
|
604 |
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
|
605 |
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
|
606 |
except ValueError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
607 |
raise error.ConfigError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
608 |
b"%s.%s is not an integer ('%s')" % (section, name, v) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
609 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
610 |
|
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
|
611 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
612 |
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
|
613 |
"""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
|
614 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
615 |
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
|
616 |
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
|
617 |
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
|
618 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
619 |
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
|
620 |
(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
|
621 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
622 |
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
|
623 |
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
|
624 |
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
|
625 |
versions. |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
626 |
""" |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
627 |
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
|
628 |
if ignoremissing: |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
629 |
return None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
630 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
631 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
632 |
b"missing attribute %s of %s might break assumption" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
633 |
b" of performance measurement" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
634 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
635 |
% (name, obj) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
636 |
) |
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
637 |
|
39826
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39779
diff
changeset
|
638 |
origvalue = getattr(obj, _sysstr(name)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
639 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
640 |
class attrutil(object): |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
641 |
def set(self, newvalue): |
39826
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39779
diff
changeset
|
642 |
setattr(obj, _sysstr(name), newvalue) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
643 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
644 |
def restore(self): |
39826
6787dc1b93a9
py3: handle sysstr conversion around get/set attr in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39779
diff
changeset
|
645 |
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
|
646 |
|
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
647 |
return attrutil() |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
648 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
649 |
|
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
|
650 |
# 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
|
651 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
652 |
|
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
|
653 |
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
|
654 |
# 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
|
655 |
# 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
|
656 |
# - 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
|
657 |
# - 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
|
658 |
# - repoviewutil since 5.0 |
caebe5e7f4bd
repoview: move subsettable in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42063
diff
changeset
|
659 |
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
|
660 |
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
|
661 |
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
|
662 |
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
|
663 |
|
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30143
diff
changeset
|
664 |
# 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
|
665 |
# 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
|
666 |
# doesn't) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
667 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
668 |
b"perfbranchmap not available with this Mercurial", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
669 |
hint=b"use 2.5 or later", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
670 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
671 |
|
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
|
672 |
|
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
|
673 |
def getsvfs(repo): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
674 |
"""Return appropriate object to access files under .hg/store""" |
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
|
675 |
# 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
|
676 |
# 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
|
677 |
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
|
678 |
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
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
683 |
|
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
|
684 |
def getvfs(repo): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
685 |
"""Return appropriate object to access files under .hg""" |
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
|
686 |
# 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
|
687 |
# 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
|
688 |
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
|
689 |
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
|
690 |
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
|
691 |
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
|
692 |
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
|
693 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
694 |
|
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
695 |
def repocleartagscachefunc(repo): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
696 |
"""Return the function to clear tags cache according to repo internal API""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
697 |
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
|
698 |
# 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
|
699 |
# 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
|
700 |
# 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
|
701 |
def clearcache(): |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
702 |
# _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
|
703 |
# 98c867ac1330), and delattr() can't work in such case |
43421
be384a2052aa
py3: don't use bytes with vars() or __dict__
Martin von Zweigbergk <martinvonz@google.com>
parents:
43197
diff
changeset
|
704 |
if '_tagscache' in vars(repo): |
be384a2052aa
py3: don't use bytes with vars() or __dict__
Martin von Zweigbergk <martinvonz@google.com>
parents:
43197
diff
changeset
|
705 |
del repo.__dict__['_tagscache'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
706 |
|
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
707 |
return clearcache |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
708 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
709 |
repotags = safeattrsetter(repo, b'_tags', ignoremissing=True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
710 |
if repotags: # since 1.4 (or 5614a628d173) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
711 |
return lambda: repotags.set(None) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
712 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
713 |
repotagscache = safeattrsetter(repo, b'tagscache', ignoremissing=True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
714 |
if repotagscache: # since 0.6 (or d7df759d0e97) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
715 |
return lambda: repotagscache.set(None) |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
716 |
|
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
717 |
# 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
|
718 |
# 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
|
719 |
# - 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
|
720 |
# in perftags() causes failure soon |
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
721 |
# - perf.py itself has been available since 1.1 (or eb240755386d) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
722 |
raise error.Abort(b"tags API of this hg command is unknown") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
723 |
|
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
724 |
|
32751
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32730
diff
changeset
|
725 |
# utilities to clear cache |
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32730
diff
changeset
|
726 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
727 |
|
40722
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
728 |
def clearfilecache(obj, attrname): |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
729 |
unfiltered = getattr(obj, 'unfiltered', None) |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
730 |
if unfiltered is not None: |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
731 |
obj = obj.unfiltered() |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
732 |
if attrname in vars(obj): |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
733 |
delattr(obj, attrname) |
d7936a9dad47
perf: make `clearfilecache` helper work with any object
Boris Feld <boris.feld@octobus.net>
parents:
40721
diff
changeset
|
734 |
obj._filecache.pop(attrname, None) |
32751
6f791ca70640
perf: have a generic "clearstorecache" function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32730
diff
changeset
|
735 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
736 |
|
40740
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40739
diff
changeset
|
737 |
def clearchangelog(repo): |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40739
diff
changeset
|
738 |
if repo is not repo.unfiltered(): |
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43551
diff
changeset
|
739 |
object.__setattr__(repo, '_clcachekey', None) |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43551
diff
changeset
|
740 |
object.__setattr__(repo, '_clcache', None) |
40740
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40739
diff
changeset
|
741 |
clearfilecache(repo.unfiltered(), 'changelog') |
e4ea63855d5a
perf: introduce a function to fully "unload" a changelog
Boris Feld <boris.feld@octobus.net>
parents:
40739
diff
changeset
|
742 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
743 |
|
30143
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
744 |
# perf commands |
2d858c771760
perf: introduce safeattrsetter to replace direct attribute assignment
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30069
diff
changeset
|
745 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
746 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
747 |
@command(b'perf::walk|perfwalk', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
748 |
def perfwalk(ui, repo, *pats, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
749 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
750 |
timer, fm = gettimer(ui, opts) |
34349
b3538c03a804
perf: remove fallbacks to ancient versions of dirstate.walk()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32906
diff
changeset
|
751 |
m = scmutil.match(repo[None], pats, {}) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
752 |
timer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
753 |
lambda: len( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
754 |
list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
755 |
repo.dirstate.walk(m, subrepos=[], unknown=True, ignored=False) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
756 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
757 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
758 |
) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
759 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
760 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
761 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
762 |
@command(b'perf::annotate|perfannotate', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
763 |
def perfannotate(ui, repo, f, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
764 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
765 |
timer, fm = gettimer(ui, opts) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
766 |
fc = repo[b'.'][f] |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
767 |
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
|
768 |
fm.end() |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
18877
diff
changeset
|
769 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
770 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
771 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
772 |
b'perf::status|perfstatus', |
43488
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
773 |
[ |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
774 |
(b'u', b'unknown', False, b'ask status to look for unknown files'), |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
775 |
(b'', b'dirstate', False, b'benchmark the internal dirstate call'), |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
776 |
] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
777 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
778 |
) |
18033
00ac420f24ee
perf: add option to perfstatus to get the status of unknown files
Siddharth Agarwal <sid0@fb.com>
parents:
17780
diff
changeset
|
779 |
def perfstatus(ui, repo, **opts): |
43120
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
780 |
"""benchmark the performance of a single status call |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
781 |
|
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
782 |
The repository data are preserved between each call. |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
783 |
|
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
784 |
By default, only the status of the tracked file are requested. If |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
785 |
`--unknown` is passed, the "unknown" files are also tracked. |
97f80dd21312
perf: document `perfstatus`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
786 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
787 |
opts = _byteskwargs(opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
788 |
# m = match.always(repo.root, repo.getcwd()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
789 |
# timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, |
16683 | 790 |
# False)))) |
27017
cdc3e437b481
perf: un-bitrot perfstatus
Matt Mackall <mpm@selenic.com>
parents:
26748
diff
changeset
|
791 |
timer, fm = gettimer(ui, opts) |
43488
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
792 |
if opts[b'dirstate']: |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
793 |
dirstate = repo.dirstate |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
794 |
m = scmutil.matchall(repo) |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
795 |
unknown = opts[b'unknown'] |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
796 |
|
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
797 |
def status_dirstate(): |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
798 |
s = dirstate.status( |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
799 |
m, subrepos=[], ignored=False, clean=False, unknown=unknown |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
800 |
) |
43697
6186c2a53ea5
perf: bool() elements of dirstate.status return instead of len()
Augie Fackler <augie@google.com>
parents:
43620
diff
changeset
|
801 |
sum(map(bool, s)) |
43488
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
802 |
|
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
803 |
timer(status_dirstate) |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
804 |
else: |
bfc68404cccd
perf: add a way to benchmark `dirstate.status`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43197
diff
changeset
|
805 |
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
|
806 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
807 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
808 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
809 |
@command(b'perf::addremove|perfaddremove', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
810 |
def perfaddremove(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
811 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
812 |
timer, fm = gettimer(ui, opts) |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
813 |
try: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
814 |
oldquiet = repo.ui.quiet |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
815 |
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
|
816 |
matcher = scmutil.match(repo[None]) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
817 |
opts[b'dry_run'] = True |
45635
7d0e54056586
py3: use native string when comparing with a function's argspec
Raphaël Gomès <rgomes@octobus.net>
parents:
45016
diff
changeset
|
818 |
if 'uipathfn' in getargspec(scmutil.addremove).args: |
41663
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41626
diff
changeset
|
819 |
uipathfn = scmutil.getuipathfn(repo) |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41626
diff
changeset
|
820 |
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:
41626
diff
changeset
|
821 |
else: |
6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41626
diff
changeset
|
822 |
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
|
823 |
finally: |
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
824 |
repo.ui.quiet = oldquiet |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
825 |
fm.end() |
18871
a2d4ab4f575d
perf: add a command to test addremove performance
Siddharth Agarwal <sid0@fb.com>
parents:
18845
diff
changeset
|
826 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
827 |
|
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
828 |
def clearcaches(cl): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
829 |
# behave somewhat consistently across internal API changes |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
830 |
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
|
831 |
cl.clearcaches() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
832 |
elif util.safehasattr(cl, b'_nodecache'): |
43575
43424f03d9a4
revlog: clarify which version use the older API in perf
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43574
diff
changeset
|
833 |
# <= hg-5.2 |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
834 |
from mercurial.node import nullid, nullrev |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
835 |
|
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
836 |
cl._nodecache = {nullid: nullrev} |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
837 |
cl._nodepos = None |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
838 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
839 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
840 |
@command(b'perf::heads|perfheads', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
841 |
def perfheads(ui, repo, **opts): |
41456
48394923fbdc
perf: document perfheads
Boris Feld <boris.feld@octobus.net>
parents:
41387
diff
changeset
|
842 |
"""benchmark the computation of a changelog heads""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
843 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
844 |
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
|
845 |
cl = repo.changelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
846 |
|
41458
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41456
diff
changeset
|
847 |
def s(): |
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41456
diff
changeset
|
848 |
clearcaches(cl) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
849 |
|
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
850 |
def d(): |
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
851 |
len(cl.headrevs()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
852 |
|
41458
ab6d1f82be32
perf: move cache clearing in the `setup` step of `perfheads`
Boris Feld <boris.feld@octobus.net>
parents:
41456
diff
changeset
|
853 |
timer(d, setup=s) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
854 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
855 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
856 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
857 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
858 |
b'perf::tags|perftags', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
859 |
formatteropts |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
860 |
+ [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
861 |
(b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
862 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
863 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
864 |
def perftags(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
865 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
866 |
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
|
867 |
repocleartagscache = repocleartagscachefunc(repo) |
40778
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40777
diff
changeset
|
868 |
clearrevlogs = opts[b'clear_revlogs'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
869 |
|
40721
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40720
diff
changeset
|
870 |
def s(): |
40778
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40777
diff
changeset
|
871 |
if clearrevlogs: |
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40777
diff
changeset
|
872 |
clearchangelog(repo) |
594e84a2e574
perf: add a `clear-revlogs` flag to `perftags`
Boris Feld <boris.feld@octobus.net>
parents:
40777
diff
changeset
|
873 |
clearfilecache(repo.unfiltered(), 'manifest') |
30150
c0410814002f
perf: make perftags clear tags cache correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30149
diff
changeset
|
874 |
repocleartagscache() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
875 |
|
40721
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40720
diff
changeset
|
876 |
def t(): |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
877 |
return len(repo.tags()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
878 |
|
40721
4369c00a8ee1
perf: move some of the perftags benchmark to the setup function
Boris Feld <boris.feld@octobus.net>
parents:
40720
diff
changeset
|
879 |
timer(t, setup=s) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
880 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
881 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
882 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
883 |
@command(b'perf::ancestors|perfancestors', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
884 |
def perfancestors(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
885 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
886 |
timer, fm = gettimer(ui, opts) |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
887 |
heads = repo.changelog.headrevs() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
888 |
|
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
889 |
def d(): |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16858
diff
changeset
|
890 |
for a in repo.changelog.ancestors(heads): |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
891 |
pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
892 |
|
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
893 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
894 |
fm.end() |
16802
7e5d94381cd1
perf: add a perfancestors benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16788
diff
changeset
|
895 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
896 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
897 |
@command(b'perf::ancestorset|perfancestorset', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
898 |
def perfancestorset(ui, repo, revset, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
899 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
900 |
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
|
901 |
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
|
902 |
heads = repo.changelog.headrevs() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
903 |
|
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
904 |
def d(): |
18091
f7f8159caad3
ancestor: add lazy membership testing to lazyancestors
Siddharth Agarwal <sid0@fb.com>
parents:
18080
diff
changeset
|
905 |
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
|
906 |
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
|
907 |
rev in s |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
908 |
|
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
909 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
910 |
fm.end() |
18080
486bfb200b3f
perf: add command to test performance of membership in ancestor set
Siddharth Agarwal <sid0@fb.com>
parents:
18062
diff
changeset
|
911 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
912 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
913 |
@command(b'perf::discovery|perfdiscovery', formatteropts, b'PATH') |
40954
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
914 |
def perfdiscovery(ui, repo, path, **opts): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
915 |
"""benchmark discovery between local repo and the peer at given path""" |
40954
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
916 |
repos = [repo, None] |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
917 |
timer, fm = gettimer(ui, opts) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
918 |
path = ui.expandpath(path) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
919 |
|
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
920 |
def s(): |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
921 |
repos[1] = hg.peer(ui, opts, path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
922 |
|
40954
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
923 |
def d(): |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
924 |
setdiscovery.findcommonheads(ui, *repos) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
925 |
|
40954
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
926 |
timer(d, setup=s) |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
927 |
fm.end() |
db6cace18765
perfdiscovery: benching findcommonheads()
Georges Racinet <gracinet@anybox.fr>
parents:
40943
diff
changeset
|
928 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
929 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
930 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
931 |
b'perf::bookmarks|perfbookmarks', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
932 |
formatteropts |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
933 |
+ [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
934 |
(b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
935 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
936 |
) |
32753
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32752
diff
changeset
|
937 |
def perfbookmarks(ui, repo, **opts): |
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32752
diff
changeset
|
938 |
"""benchmark parsing bookmarks from disk to memory""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
939 |
opts = _byteskwargs(opts) |
32753
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32752
diff
changeset
|
940 |
timer, fm = gettimer(ui, opts) |
40720
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
941 |
|
40780
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40778
diff
changeset
|
942 |
clearrevlogs = opts[b'clear_revlogs'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
943 |
|
40720
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
944 |
def s(): |
40780
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40778
diff
changeset
|
945 |
if clearrevlogs: |
82c189c511bd
perf: add a `clear-revlogs` flag to `perfbookmarks`
Boris Feld <boris.feld@octobus.net>
parents:
40778
diff
changeset
|
946 |
clearchangelog(repo) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
947 |
clearfilecache(repo, b'_bookmarks') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
948 |
|
40720
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
949 |
def d(): |
32753
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32752
diff
changeset
|
950 |
repo._bookmarks |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
951 |
|
40720
c0a1686d9391
perf: use the new setup function in "perfbookmarks"
Boris Feld <boris.feld@octobus.net>
parents:
40719
diff
changeset
|
952 |
timer(d, setup=s) |
32753
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32752
diff
changeset
|
953 |
fm.end() |
2b0a8b0f3435
perf: add a perfbookmarks command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32752
diff
changeset
|
954 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
955 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
956 |
@command(b'perf::bundleread|perfbundleread', formatteropts, b'BUNDLE') |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
957 |
def perfbundleread(ui, repo, bundlepath, **opts): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
958 |
"""Benchmark reading of bundle files. |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
959 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
960 |
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:
35107
diff
changeset
|
961 |
much as possible. |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
962 |
""" |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
963 |
from mercurial import ( |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
964 |
bundle2, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
965 |
exchange, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
966 |
streamclone, |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
967 |
) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
968 |
|
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
969 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
970 |
|
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
971 |
def makebench(fn): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
972 |
def run(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
973 |
with open(bundlepath, b'rb') as fh: |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
974 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
975 |
fn(bundle) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
976 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
977 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
978 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
979 |
def makereadnbytes(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
980 |
def run(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
981 |
with open(bundlepath, b'rb') as fh: |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
982 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
983 |
while bundle.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
984 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
985 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
986 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
987 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
988 |
def makestdioread(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
989 |
def run(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
990 |
with open(bundlepath, b'rb') as fh: |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
991 |
while fh.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
992 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
993 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
994 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
995 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
996 |
# bundle1 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
997 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
998 |
def deltaiter(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
999 |
for delta in bundle.deltaiter(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1000 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1001 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1002 |
def iterchunks(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1003 |
for chunk in bundle.getchunks(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1004 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1005 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1006 |
# bundle2 |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1007 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1008 |
def forwardchunks(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1009 |
for chunk in bundle._forwardchunks(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1010 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1011 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1012 |
def iterparts(bundle): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1013 |
for part in bundle.iterparts(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1014 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1015 |
|
35137
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35132
diff
changeset
|
1016 |
def iterpartsseekable(bundle): |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35132
diff
changeset
|
1017 |
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:
35132
diff
changeset
|
1018 |
pass |
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35132
diff
changeset
|
1019 |
|
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1020 |
def seek(bundle): |
35137
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35132
diff
changeset
|
1021 |
for part in bundle.iterparts(seekable=True): |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1022 |
part.seek(0, os.SEEK_END) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1023 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1024 |
def makepartreadnbytes(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1025 |
def run(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1026 |
with open(bundlepath, b'rb') as fh: |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1027 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1028 |
for part in bundle.iterparts(): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1029 |
while part.read(size): |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1030 |
pass |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1031 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1032 |
return run |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1033 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1034 |
benches = [ |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1035 |
(makestdioread(8192), b'read(8k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1036 |
(makestdioread(16384), b'read(16k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1037 |
(makestdioread(32768), b'read(32k)'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1038 |
(makestdioread(131072), b'read(128k)'), |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1039 |
] |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1040 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1041 |
with open(bundlepath, b'rb') as fh: |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1042 |
bundle = exchange.readbundle(ui, fh, bundlepath) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1043 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1044 |
if isinstance(bundle, changegroup.cg1unpacker): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1045 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1046 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1047 |
(makebench(deltaiter), b'cg1 deltaiter()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1048 |
(makebench(iterchunks), b'cg1 getchunks()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1049 |
(makereadnbytes(8192), b'cg1 read(8k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1050 |
(makereadnbytes(16384), b'cg1 read(16k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1051 |
(makereadnbytes(32768), b'cg1 read(32k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1052 |
(makereadnbytes(131072), b'cg1 read(128k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1053 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1054 |
) |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1055 |
elif isinstance(bundle, bundle2.unbundle20): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1056 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1057 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1058 |
(makebench(forwardchunks), b'bundle2 forwardchunks()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1059 |
(makebench(iterparts), b'bundle2 iterparts()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1060 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1061 |
makebench(iterpartsseekable), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1062 |
b'bundle2 iterparts() seekable', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1063 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1064 |
(makebench(seek), b'bundle2 part seek()'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1065 |
(makepartreadnbytes(8192), b'bundle2 part read(8k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1066 |
(makepartreadnbytes(16384), b'bundle2 part read(16k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1067 |
(makepartreadnbytes(32768), b'bundle2 part read(32k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1068 |
(makepartreadnbytes(131072), b'bundle2 part read(128k)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1069 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1070 |
) |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1071 |
elif isinstance(bundle, streamclone.streamcloneapplier): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1072 |
raise error.Abort(b'stream clone bundles not supported') |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1073 |
else: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1074 |
raise error.Abort(b'unhandled bundle type: %s' % type(bundle)) |
35132
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1075 |
|
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1076 |
for fn, title in benches: |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1077 |
timer, fm = gettimer(ui, opts) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1078 |
timer(fn, title=title) |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1079 |
fm.end() |
e96613048bdd
perf: add command to benchmark bundle reading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35107
diff
changeset
|
1080 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1081 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1082 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1083 |
b'perf::changegroupchangelog|perfchangegroupchangelog', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1084 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1085 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1086 |
(b'', b'cgversion', b'02', b'changegroup version'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1087 |
(b'r', b'rev', b'', b'revisions to add to changegroup'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1088 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1089 |
) |
40752
cfaf3843491b
perf: rename version flag of perfchangegroupchangelog to cgversion
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40741
diff
changeset
|
1090 |
def perfchangegroupchangelog(ui, repo, cgversion=b'02', rev=None, **opts): |
30020
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1091 |
"""Benchmark producing a changelog group for a changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1092 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1093 |
This measures the time spent processing the changelog during a |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1094 |
bundle operation. This occurs during `hg bundle` and on a server |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1095 |
processing a `getbundle` wire protocol request (handles clones |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1096 |
and pull requests). |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1097 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1098 |
By default, all revisions are added to the changegroup. |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1099 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1100 |
opts = _byteskwargs(opts) |
30020
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1101 |
cl = repo.changelog |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1102 |
nodes = [cl.lookup(r) for r in repo.revs(rev or b'all()')] |
40752
cfaf3843491b
perf: rename version flag of perfchangegroupchangelog to cgversion
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40741
diff
changeset
|
1103 |
bundler = changegroup.getbundler(cgversion, repo) |
30020
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1104 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1105 |
def d(): |
39015
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39007
diff
changeset
|
1106 |
state, chunks = bundler._generatechangelog(cl, nodes) |
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39007
diff
changeset
|
1107 |
for chunk in chunks: |
30020
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1108 |
pass |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1109 |
|
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1110 |
timer, fm = gettimer(ui, opts) |
39015
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39007
diff
changeset
|
1111 |
|
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39007
diff
changeset
|
1112 |
# Terminal printing can interfere with timing. So disable it. |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1113 |
with ui.configoverride({(b'progress', b'disable'): True}): |
39015
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39007
diff
changeset
|
1114 |
timer(d) |
a1f694779b2f
perf: call _generatechangelog() instead of group()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39007
diff
changeset
|
1115 |
|
30020
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1116 |
fm.end() |
bd6df07ccc24
perf: add perfchangegroupchangelog command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30019
diff
changeset
|
1117 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1118 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1119 |
@command(b'perf::dirs|perfdirs', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1120 |
def perfdirs(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
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) |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1123 |
dirstate = repo.dirstate |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1124 |
b'a' in dirstate |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1125 |
|
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1126 |
def d(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1127 |
dirstate.hasdir(b'a') |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
34750
diff
changeset
|
1128 |
del dirstate._map._dirs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1129 |
|
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1130 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1131 |
fm.end() |
18845
c1f416e4bc80
perf: add perfdirs command
Bryan O'Sullivan <bryano@fb.com>
parents:
18837
diff
changeset
|
1132 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1133 |
|
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1134 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1135 |
b'perf::dirstate|perfdirstate', |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1136 |
[ |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1137 |
( |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1138 |
b'', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1139 |
b'iteration', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1140 |
None, |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1141 |
b'benchmark a full iteration for the dirstate', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1142 |
), |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1143 |
( |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1144 |
b'', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1145 |
b'contains', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1146 |
None, |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1147 |
b'benchmark a large amount of `nf in dirstate` calls', |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1148 |
), |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1149 |
] |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1150 |
+ formatteropts, |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1151 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1152 |
def perfdirstate(ui, repo, **opts): |
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1153 |
"""benchmap the time of various distate operations |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1154 |
|
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1155 |
By default benchmark the time necessary to load a dirstate from scratch. |
43121
ce315b1fc9a7
perf: document `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43120
diff
changeset
|
1156 |
The dirstate is loaded to the point were a "contains" request can be |
ce315b1fc9a7
perf: document `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43120
diff
changeset
|
1157 |
answered. |
ce315b1fc9a7
perf: document `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43120
diff
changeset
|
1158 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1159 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1160 |
timer, fm = gettimer(ui, opts) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1161 |
b"a" in repo.dirstate |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1162 |
|
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1163 |
if opts[b'iteration'] and opts[b'contains']: |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1164 |
msg = b'only specify one of --iteration or --contains' |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1165 |
raise error.Abort(msg) |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1166 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1167 |
if opts[b'iteration']: |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1168 |
setup = None |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1169 |
dirstate = repo.dirstate |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1170 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1171 |
def d(): |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1172 |
for f in dirstate: |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1173 |
pass |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1174 |
|
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1175 |
elif opts[b'contains']: |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1176 |
setup = None |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1177 |
dirstate = repo.dirstate |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1178 |
allfiles = list(dirstate) |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1179 |
# also add file path that will be "missing" from the dirstate |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1180 |
allfiles.extend([f[::-1] for f in allfiles]) |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1181 |
|
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1182 |
def d(): |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1183 |
for f in allfiles: |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1184 |
f in dirstate |
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1185 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1186 |
else: |
43197
0c4efb6eb4fa
perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43196
diff
changeset
|
1187 |
|
43196
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1188 |
def setup(): |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1189 |
repo.dirstate.invalidate() |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1190 |
|
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1191 |
def d(): |
5f9b1250b82a
perf: introduce a `--iteration` to `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43161
diff
changeset
|
1192 |
b"a" in repo.dirstate |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1193 |
|
43122
436a6a31df38
perf: use `setup` function in `perfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43121
diff
changeset
|
1194 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1195 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1196 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1197 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1198 |
@command(b'perf::dirstatedirs|perfdirstatedirs', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1199 |
def perfdirstatedirs(ui, repo, **opts): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1200 |
"""benchmap a 'dirstate.hasdir' call from an empty `dirs` cache""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1201 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1202 |
timer, fm = gettimer(ui, opts) |
43124
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1203 |
repo.dirstate.hasdir(b"a") |
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1204 |
|
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1205 |
def setup(): |
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1206 |
del repo.dirstate._map._dirs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1207 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1208 |
def d(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1209 |
repo.dirstate.hasdir(b"a") |
43124
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1210 |
|
100e7e0cdaad
perf: use `setup` function in `perfdirstatedirs`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43123
diff
changeset
|
1211 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1212 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1213 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1214 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1215 |
@command(b'perf::dirstatefoldmap|perfdirstatefoldmap', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
1216 |
def perfdirstatefoldmap(ui, repo, **opts): |
43125
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1217 |
"""benchmap a `dirstate._map.filefoldmap.get()` request |
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1218 |
|
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1219 |
The dirstate filefoldmap cache is dropped between every request. |
56494a2bfe2f
perf: document `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43124
diff
changeset
|
1220 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1221 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1222 |
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
|
1223 |
dirstate = repo.dirstate |
43126
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1224 |
dirstate._map.filefoldmap.get(b'a') |
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1225 |
|
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1226 |
def setup(): |
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1227 |
del dirstate._map.filefoldmap |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1228 |
|
22780
d8ff1f671aed
perf: add a way to measure the perf of constructing the foldmap
Siddharth Agarwal <sid0@fb.com>
parents:
20846
diff
changeset
|
1229 |
def d(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1230 |
dirstate._map.filefoldmap.get(b'a') |
43126
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1231 |
|
e337d8247375
perf: use `setup` function in `perfdirstatefoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43125
diff
changeset
|
1232 |
timer(d, setup=setup) |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1233 |
fm.end() |
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1234 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1235 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1236 |
@command(b'perf::dirfoldmap|perfdirfoldmap', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1237 |
def perfdirfoldmap(ui, repo, **opts): |
43127
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1238 |
"""benchmap a `dirstate._map.dirfoldmap.get()` request |
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1239 |
|
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1240 |
The dirstate dirfoldmap cache is dropped between every request. |
0b32206c3c86
perf: document `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43126
diff
changeset
|
1241 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1242 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1243 |
timer, fm = gettimer(ui, opts) |
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1244 |
dirstate = repo.dirstate |
43128
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1245 |
dirstate._map.dirfoldmap.get(b'a') |
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1246 |
|
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1247 |
def setup(): |
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1248 |
del dirstate._map.dirfoldmap |
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1249 |
del dirstate._map._dirs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1250 |
|
24607
f5b527024fcc
perf: make measuring foldmap perf work again
Siddharth Agarwal <sid0@fb.com>
parents:
24349
diff
changeset
|
1251 |
def d(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1252 |
dirstate._map.dirfoldmap.get(b'a') |
43128
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1253 |
|
ad801d4af7cd
perf: use `setup` function in `perfdirfoldmap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43127
diff
changeset
|
1254 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1255 |
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
|
1256 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1257 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1258 |
@command(b'perf::dirstatewrite|perfdirstatewrite', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1259 |
def perfdirstatewrite(ui, repo, **opts): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1260 |
"""benchmap the time it take to write a dirstate on disk""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1261 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1262 |
timer, fm = gettimer(ui, opts) |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
1263 |
ds = repo.dirstate |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1264 |
b"a" in ds |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1265 |
|
43130
c88075eb28e3
perf: use `setup` function in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43129
diff
changeset
|
1266 |
def setup(): |
c88075eb28e3
perf: use `setup` function in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43129
diff
changeset
|
1267 |
ds._dirty = True |
c88075eb28e3
perf: use `setup` function in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43129
diff
changeset
|
1268 |
|
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
1269 |
def d(): |
26748
5ba0a99ff27f
dirstate: make dirstate.write() callers pass transaction object to it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25850
diff
changeset
|
1270 |
ds.write(repo.currenttransaction()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1271 |
|
43130
c88075eb28e3
perf: use `setup` function in `perfdirstatewrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43129
diff
changeset
|
1272 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1273 |
fm.end() |
16788
7e72c1609862
perf: add a perfdirstatewrite benchmark
Bryan O'Sullivan <bryano@fb.com>
parents:
16785
diff
changeset
|
1274 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1275 |
|
42402
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1276 |
def _getmergerevs(repo, opts): |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1277 |
"""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:
42401
diff
changeset
|
1278 |
|
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1279 |
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:
42401
diff
changeset
|
1280 |
output: (localctx, otherctx, basectx) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1281 |
""" |
42411
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42404
diff
changeset
|
1282 |
if opts[b'from']: |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42404
diff
changeset
|
1283 |
fromrev = scmutil.revsingle(repo, opts[b'from']) |
42400
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42392
diff
changeset
|
1284 |
wctx = repo[fromrev] |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42392
diff
changeset
|
1285 |
else: |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42392
diff
changeset
|
1286 |
wctx = repo[None] |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42392
diff
changeset
|
1287 |
# 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:
42392
diff
changeset
|
1288 |
# prime that cache |
e3ee707d42ad
perf: add a --from flag to perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42392
diff
changeset
|
1289 |
wctx.dirty() |
42411
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42404
diff
changeset
|
1290 |
rctx = scmutil.revsingle(repo, opts[b'rev'], opts[b'rev']) |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42404
diff
changeset
|
1291 |
if opts[b'base']: |
4372d56112c9
perf: fix some missing b prefixes
Augie Fackler <augie@google.com>
parents:
42404
diff
changeset
|
1292 |
fromrev = scmutil.revsingle(repo, opts[b'base']) |
42401
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42400
diff
changeset
|
1293 |
ancestor = repo[fromrev] |
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42400
diff
changeset
|
1294 |
else: |
f0bcbbb6541c
perf: allow to specify the base of the merge in perfmergecalculate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42400
diff
changeset
|
1295 |
ancestor = wctx.ancestor(rctx) |
42402
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1296 |
return (wctx, rctx, ancestor) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1297 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1298 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1299 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1300 |
b'perf::mergecalculate|perfmergecalculate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1301 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1302 |
(b'r', b'rev', b'.', b'rev to merge against'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1303 |
(b'', b'from', b'', b'rev to merge from'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1304 |
(b'', b'base', b'', b'the revision to use as base'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1305 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1306 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1307 |
) |
42402
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1308 |
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:
42401
diff
changeset
|
1309 |
opts = _byteskwargs(opts) |
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1310 |
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:
42401
diff
changeset
|
1311 |
|
3a3592b40a95
perf: factor selection of revisions involved in the merge out
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42401
diff
changeset
|
1312 |
wctx, rctx, ancestor = _getmergerevs(repo, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1313 |
|
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1314 |
def d(): |
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1315 |
# 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
|
1316 |
# our benchmark |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1317 |
merge.calculateupdates( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1318 |
repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1319 |
wctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1320 |
rctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1321 |
[ancestor], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1322 |
branchmerge=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1323 |
force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1324 |
acceptremote=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1325 |
followcopies=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1326 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1327 |
|
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1328 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1329 |
fm.end() |
18817
c760acc6f69d
perf: add a command to measure merge.calculateupdates perf
Siddharth Agarwal <sid0@fb.com>
parents:
18644
diff
changeset
|
1330 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1331 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1332 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1333 |
b'perf::mergecopies|perfmergecopies', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1334 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1335 |
(b'r', b'rev', b'.', b'rev to merge against'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1336 |
(b'', b'from', b'', b'rev to merge from'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1337 |
(b'', b'base', b'', b'the revision to use as base'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1338 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1339 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1340 |
) |
42403
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1341 |
def perfmergecopies(ui, repo, **opts): |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1342 |
"""measure runtime of `copies.mergecopies`""" |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1343 |
opts = _byteskwargs(opts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1344 |
timer, fm = gettimer(ui, opts) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1345 |
wctx, rctx, ancestor = _getmergerevs(repo, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1346 |
|
42403
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1347 |
def d(): |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1348 |
# 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:
42402
diff
changeset
|
1349 |
# our benchmark |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1350 |
copies.mergecopies(repo, wctx, rctx, ancestor) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1351 |
|
42403
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1352 |
timer(d) |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1353 |
fm.end() |
f5f0a9490c05
perf: add a new `perfmergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42402
diff
changeset
|
1354 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1355 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1356 |
@command(b'perf::pathcopies|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
|
1357 |
def perfpathcopies(ui, repo, rev1, rev2, **opts): |
40773
dc3ab5e5fe64
perf: add a docstring to `perfpathcopies`
Boris Feld <boris.feld@octobus.net>
parents:
40765
diff
changeset
|
1358 |
"""benchmark the copy tracing logic""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1359 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1360 |
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
|
1361 |
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
|
1362 |
ctx2 = scmutil.revsingle(repo, rev2, rev2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1363 |
|
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1364 |
def d(): |
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1365 |
copies.pathcopies(ctx1, ctx2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1366 |
|
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1367 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1368 |
fm.end() |
18877
2e9fe9e2671f
perf: add a command to test copies.pathcopies perf
Siddharth Agarwal <sid0@fb.com>
parents:
18871
diff
changeset
|
1369 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1370 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1371 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1372 |
b'perf::phases|perfphases', |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1373 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1374 |
(b'', b'full', False, b'include file reading time too'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1375 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1376 |
b"", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1377 |
) |
32501
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1378 |
def perfphases(ui, repo, **opts): |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1379 |
"""benchmark phasesets computation""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1380 |
opts = _byteskwargs(opts) |
32501
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1381 |
timer, fm = gettimer(ui, opts) |
32752
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32751
diff
changeset
|
1382 |
_phases = repo._phasecache |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1383 |
full = opts.get(b'full') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1384 |
|
32501
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1385 |
def d(): |
32752
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32751
diff
changeset
|
1386 |
phases = _phases |
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32751
diff
changeset
|
1387 |
if full: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1388 |
clearfilecache(repo, b'_phasecache') |
32752
e36569bd9e28
perfphases: add a flag to also include file access time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32751
diff
changeset
|
1389 |
phases = repo._phasecache |
32501
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1390 |
phases.invalidate() |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1391 |
phases.loadphaserevs(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1392 |
|
32501
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1393 |
timer(d) |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1394 |
fm.end() |
ad37c569ec81
perfphases: add 'perfphases' command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32428
diff
changeset
|
1395 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1396 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1397 |
@command(b'perf::phasesremote|perfphasesremote', [], b"[DEST]") |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1398 |
def perfphasesremote(ui, repo, dest=None, **opts): |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1399 |
"""benchmark time needed to analyse phases of the remote server""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1400 |
from mercurial.node import bin |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1401 |
from mercurial import ( |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1402 |
exchange, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1403 |
hg, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1404 |
phases, |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1405 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1406 |
|
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1407 |
opts = _byteskwargs(opts) |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1408 |
timer, fm = gettimer(ui, opts) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1409 |
|
46733
66fb04552122
ui: pass a `ui` object to `paths.getpath`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46460
diff
changeset
|
1410 |
path = ui.getpath(dest, default=(b'default-push', b'default')) |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1411 |
if not path: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1412 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1413 |
b'default repository not configured!', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1414 |
hint=b"see 'hg help config.paths'", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1415 |
) |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1416 |
dest = path.pushloc or path.loc |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1417 |
ui.statusnoi18n(b'analysing phase of %s\n' % util.hidepassword(dest)) |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1418 |
other = hg.peer(repo, opts, dest) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1419 |
|
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1420 |
# easier to perform discovery through the operation |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1421 |
op = exchange.pushoperation(repo, other) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1422 |
exchange._pushdiscoverychangeset(op) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1423 |
|
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1424 |
remotesubset = op.fallbackheads |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1425 |
|
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1426 |
with other.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1427 |
remotephases = e.callcommand( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1428 |
b'listkeys', {b'namespace': b'phases'} |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1429 |
).result() |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1430 |
del other |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1431 |
publishing = remotephases.get(b'publishing', False) |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1432 |
if publishing: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1433 |
ui.statusnoi18n(b'publishing: yes\n') |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1434 |
else: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1435 |
ui.statusnoi18n(b'publishing: no\n') |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1436 |
|
43599
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43575
diff
changeset
|
1437 |
has_node = getattr(repo.changelog.index, 'has_node', None) |
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43575
diff
changeset
|
1438 |
if has_node is None: |
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43575
diff
changeset
|
1439 |
has_node = repo.changelog.nodemap.__contains__ |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1440 |
nonpublishroots = 0 |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1441 |
for nhex, phase in remotephases.iteritems(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1442 |
if nhex == b'publishing': # ignore data related to publish option |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1443 |
continue |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1444 |
node = bin(nhex) |
43599
3350d7aefe67
perf: make `perfphasesremote` use the new `index.has_node` api
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43575
diff
changeset
|
1445 |
if has_node(node) and int(phase): |
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1446 |
nonpublishroots += 1 |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1447 |
ui.statusnoi18n(b'number of roots: %d\n' % len(remotephases)) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1448 |
ui.statusnoi18n(b'number of known non public roots: %d\n' % nonpublishroots) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1449 |
|
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1450 |
def d(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1451 |
phases.remotephasessummary(repo, remotesubset, remotephases) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1452 |
|
38771
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1453 |
timer(d) |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1454 |
fm.end() |
1732db2f8210
perf: add a perfphasesremote command
Boris Feld <boris.feld@octobus.net>
parents:
38695
diff
changeset
|
1455 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1456 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1457 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1458 |
b'perf::manifest|perfmanifest', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1459 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1460 |
(b'm', b'manifest-rev', False, b'Look up a manifest node revision'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1461 |
(b'', b'clear-disk', False, b'clear on-disk caches too'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1462 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1463 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1464 |
b'REV|NODE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1465 |
) |
38820
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38819
diff
changeset
|
1466 |
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:
38285
diff
changeset
|
1467 |
"""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:
38285
diff
changeset
|
1468 |
dict-like object |
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38285
diff
changeset
|
1469 |
|
9b6a708f2263
perf: document the perfmanifest command
Boris Feld <boris.feld@octobus.net>
parents:
38285
diff
changeset
|
1470 |
Manifest caches are cleared before retrieval.""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1471 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1472 |
timer, fm = gettimer(ui, opts) |
38820
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38819
diff
changeset
|
1473 |
if not manifest_rev: |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38819
diff
changeset
|
1474 |
ctx = scmutil.revsingle(repo, rev, rev) |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38819
diff
changeset
|
1475 |
t = ctx.manifestnode() |
ddb15a83ae0b
debug: allow specifying a manifest node rather than a revision
Martijn Pieters <mj@zopatista.com>
parents:
38819
diff
changeset
|
1476 |
else: |
39345
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1477 |
from mercurial.node import bin |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1478 |
|
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1479 |
if len(rev) == 40: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1480 |
t = bin(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1481 |
else: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1482 |
try: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1483 |
rev = int(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1484 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1485 |
if util.safehasattr(repo.manifestlog, b'getstorage'): |
39345
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1486 |
t = repo.manifestlog.getstorage(b'').node(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1487 |
else: |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1488 |
t = repo.manifestlog._revlog.lookup(rev) |
c03c5f528e9b
perf: use storage API for resolving manifest node
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39226
diff
changeset
|
1489 |
except ValueError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1490 |
raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43080
diff
changeset
|
1491 |
b'manifest revision must be integer or full node' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1492 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1493 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1494 |
def d(): |
38821
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38820
diff
changeset
|
1495 |
repo.manifestlog.clearcaches(clear_persisted_data=clear_disk) |
30379
d79c141fdf41
manifest: remove usages of manifest.read
Durham Goode <durham@fb.com>
parents:
30347
diff
changeset
|
1496 |
repo.manifestlog[t].read() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1497 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1498 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1499 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1500 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1501 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1502 |
@command(b'perf::changeset|perfchangeset', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1503 |
def perfchangeset(ui, repo, rev, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1504 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1505 |
timer, fm = gettimer(ui, opts) |
37355
5bcd5859b505
perf: make perfmanifest and perfnodelookup work with revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37271
diff
changeset
|
1506 |
n = scmutil.revsingle(repo, rev).node() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1507 |
|
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1508 |
def d(): |
19378
9de689d20230
cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents:
19322
diff
changeset
|
1509 |
repo.changelog.read(n) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1510 |
# repo.changelog._cache = None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1511 |
|
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1512 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1513 |
fm.end() |
16262
bf7a6c3b2a4a
perf: add perfchangeset to time changeset parsing
Matt Mackall <mpm@selenic.com>
parents:
16260
diff
changeset
|
1514 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1515 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1516 |
@command(b'perf::ignore|perfignore', formatteropts) |
40784
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1517 |
def perfignore(ui, repo, **opts): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1518 |
"""benchmark operation related to computing ignore""" |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1519 |
opts = _byteskwargs(opts) |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1520 |
timer, fm = gettimer(ui, opts) |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1521 |
dirstate = repo.dirstate |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1522 |
|
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1523 |
def setupone(): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1524 |
dirstate.invalidate() |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1525 |
clearfilecache(dirstate, b'_ignore') |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1526 |
|
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1527 |
def runone(): |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1528 |
dirstate._ignore |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1529 |
|
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1530 |
timer(runone, setup=setupone, title=b"load") |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1531 |
fm.end() |
45a0047c0ebc
perf: add a perfignore command
Boris Feld <boris.feld@octobus.net>
parents:
40781
diff
changeset
|
1532 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1533 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1534 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1535 |
b'perf::index|perfindex', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1536 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1537 |
(b'', b'rev', [], b'revision to be looked up (default tip)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1538 |
(b'', b'no-lookup', None, b'do not revision lookup post creation'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1539 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1540 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1541 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1542 |
def perfindex(ui, repo, **opts): |
41459
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41458
diff
changeset
|
1543 |
"""benchmark index creation time followed by a lookup |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41458
diff
changeset
|
1544 |
|
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41458
diff
changeset
|
1545 |
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:
41458
diff
changeset
|
1546 |
the revision looked up can matters. For example, an implementation |
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41458
diff
changeset
|
1547 |
scanning the index will have a faster lookup time for `--rev tip` than for |
41461
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1548 |
`--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:
41460
diff
changeset
|
1549 |
matters. |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1550 |
|
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1551 |
Example of useful set to test: |
44307
216fc4633800
perf: fix list formatting in perfindex documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43981
diff
changeset
|
1552 |
|
41461
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1553 |
* tip |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1554 |
* 0 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1555 |
* -10: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1556 |
* :10 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1557 |
* -10: + :10 |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1558 |
* :10: + -10: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1559 |
* -10000: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1560 |
* -10000: + 0 |
41459
d65ba1ff4559
perf: add some documentation to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41458
diff
changeset
|
1561 |
|
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1562 |
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:
41461
diff
changeset
|
1563 |
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
|
1564 |
import mercurial.revlog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1565 |
|
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1566 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1567 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1568 |
mercurial.revlog._prereadsize = 2 ** 24 # disable lazy parser in old hg |
41460
e9891c734bf8
perf: add a no-lookup variant to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41459
diff
changeset
|
1569 |
if opts[b'no_lookup']: |
41461
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1570 |
if opts['rev']: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1571 |
raise error.Abort('--no-lookup and --rev are mutually exclusive') |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1572 |
nodes = [] |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1573 |
elif not opts[b'rev']: |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1574 |
nodes = [repo[b"tip"].node()] |
40818
a0f2641ddd61
perf: add a --rev attribute to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
40817
diff
changeset
|
1575 |
else: |
41461
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1576 |
revs = scmutil.revrange(repo, opts[b'rev']) |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1577 |
cl = repo.changelog |
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1578 |
nodes = [cl.node(r) for r in revs] |
40817
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1579 |
|
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1580 |
unfi = repo.unfiltered() |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1581 |
# find the filecache func directly |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1582 |
# This avoid polluting the benchmark with the filecache logic |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1583 |
makecl = unfi.__class__.changelog.func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1584 |
|
40817
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1585 |
def setup(): |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1586 |
# probably not necessary, but for good measure |
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1587 |
clearchangelog(unfi) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1588 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1589 |
def d(): |
40817
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1590 |
cl = makecl(unfi) |
41461
7eb7637e34bf
perf: support looking up multiple revisions
Boris Feld <boris.feld@octobus.net>
parents:
41460
diff
changeset
|
1591 |
for n in nodes: |
41460
e9891c734bf8
perf: add a no-lookup variant to perfindex
Boris Feld <boris.feld@octobus.net>
parents:
41459
diff
changeset
|
1592 |
cl.rev(n) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1593 |
|
40817
e207f0d6c243
perf: update perfindex to be more realistic
Boris Feld <boris.feld@octobus.net>
parents:
40806
diff
changeset
|
1594 |
timer(d, setup=setup) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1595 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1596 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1597 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1598 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1599 |
b'perf::nodemap|perfnodemap', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1600 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1601 |
(b'', b'rev', [], b'revision to be looked up (default tip)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1602 |
(b'', b'clear-caches', True, b'clear revlog cache between calls'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1603 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1604 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1605 |
) |
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1606 |
def perfnodemap(ui, repo, **opts): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1607 |
"""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:
41461
diff
changeset
|
1608 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1609 |
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:
41461
diff
changeset
|
1610 |
up can varies. Example of useful set to test: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1611 |
* tip |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1612 |
* 0 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1613 |
* -10: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1614 |
* :10 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1615 |
* -10: + :10 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1616 |
* :10: + -10: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1617 |
* -10000: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1618 |
* -10000: + 0 |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1619 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1620 |
The command currently focus on valid binary lookup. Benchmarking for |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1621 |
hexlookup, prefix lookup and missing lookup would also be valuable. |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1622 |
""" |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1623 |
import mercurial.revlog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1624 |
|
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1625 |
opts = _byteskwargs(opts) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1626 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1627 |
mercurial.revlog._prereadsize = 2 ** 24 # disable lazy parser in old hg |
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1628 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1629 |
unfi = repo.unfiltered() |
46196
96b73671753a
contrib: py3 compat for perfnodemap
Joerg Sonnenberger <joerg@bec.de>
parents:
45957
diff
changeset
|
1630 |
clearcaches = opts[b'clear_caches'] |
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1631 |
# find the filecache func directly |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1632 |
# This avoid polluting the benchmark with the filecache logic |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1633 |
makecl = unfi.__class__.changelog.func |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1634 |
if not opts[b'rev']: |
46196
96b73671753a
contrib: py3 compat for perfnodemap
Joerg Sonnenberger <joerg@bec.de>
parents:
45957
diff
changeset
|
1635 |
raise error.Abort(b'use --rev to specify revisions to look up') |
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1636 |
revs = scmutil.revrange(repo, opts[b'rev']) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1637 |
cl = repo.changelog |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1638 |
nodes = [cl.node(r) for r in revs] |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1639 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1640 |
# 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:
41461
diff
changeset
|
1641 |
nodeget = [None] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1642 |
|
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1643 |
def setnodeget(): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1644 |
# probably not necessary, but for good measure |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1645 |
clearchangelog(unfi) |
43619
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43599
diff
changeset
|
1646 |
cl = makecl(unfi) |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43599
diff
changeset
|
1647 |
if util.safehasattr(cl.index, 'get_rev'): |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43599
diff
changeset
|
1648 |
nodeget[0] = cl.index.get_rev |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43599
diff
changeset
|
1649 |
else: |
22cd0064370d
perf: make `perfnodemap` use the new `index.get_rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43599
diff
changeset
|
1650 |
nodeget[0] = cl.nodemap.get |
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1651 |
|
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1652 |
def d(): |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1653 |
get = nodeget[0] |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1654 |
for n in nodes: |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1655 |
get(n) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1656 |
|
41484
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41483
diff
changeset
|
1657 |
setup = None |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41483
diff
changeset
|
1658 |
if clearcaches: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1659 |
|
41484
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41483
diff
changeset
|
1660 |
def setup(): |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41483
diff
changeset
|
1661 |
setnodeget() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1662 |
|
41484
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41483
diff
changeset
|
1663 |
else: |
d1a273074f62
perf: add a --[no-]clear-caches option to `perfnodemap`
Boris Feld <boris.feld@octobus.net>
parents:
41483
diff
changeset
|
1664 |
setnodeget() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1665 |
d() # prewarm the data structure |
41483
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1666 |
timer(d, setup=setup) |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1667 |
fm.end() |
c9ff93889550
perf: add a perfnodemap command
Boris Feld <boris.feld@octobus.net>
parents:
41461
diff
changeset
|
1668 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1669 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1670 |
@command(b'perf::startup|perfstartup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1671 |
def perfstartup(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1672 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1673 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1674 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1675 |
def d(): |
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43551
diff
changeset
|
1676 |
if os.name != 'nt': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1677 |
os.system( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1678 |
b"HGRCPATH= %s version -q > /dev/null" % fsencode(sys.argv[0]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1679 |
) |
27382
de7bcbc68042
perf: adjust perfstartup() for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
27345
diff
changeset
|
1680 |
else: |
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43551
diff
changeset
|
1681 |
os.environ['HGRCPATH'] = r' ' |
43551
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43543
diff
changeset
|
1682 |
os.system("%s version -q > NUL" % sys.argv[0]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1683 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1684 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1685 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1686 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1687 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1688 |
@command(b'perf::parents|perfparents', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1689 |
def perfparents(ui, repo, **opts): |
42016
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
1690 |
"""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
|
1691 |
|
42021
4c700c847aa2
perf: copyedit a few documentation strings
Augie Fackler <augie@google.com>
parents:
42019
diff
changeset
|
1692 |
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
|
1693 |
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
|
1694 |
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
|
1695 |
(default: 1000). |
b900b392c1cc
perf: document perfparents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42015
diff
changeset
|
1696 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1697 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1698 |
timer, fm = gettimer(ui, opts) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
1699 |
# control the number of commits perfparents iterates over |
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
1700 |
# experimental config: perf.parentscount |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1701 |
count = getint(ui, b"perf", b"parentscount", 1000) |
27305
5831cfbf0e33
perf: perfparents honor config perf.parentscount
timeless <timeless@mozdev.org>
parents:
27304
diff
changeset
|
1702 |
if len(repo.changelog) < count: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1703 |
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
|
1704 |
repo = repo.unfiltered() |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
1705 |
nl = [repo.changelog.node(i) for i in _xrange(count)] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1706 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1707 |
def d(): |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1708 |
for n in nl: |
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1709 |
repo.changelog.parents(n) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1710 |
|
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1711 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1712 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1713 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1714 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1715 |
@command(b'perf::ctxfiles|perfctxfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
1716 |
def perfctxfiles(ui, repo, x, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1717 |
opts = _byteskwargs(opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1718 |
x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1719 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1720 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1721 |
def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1722 |
len(repo[x].files()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1723 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1724 |
timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1725 |
fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1726 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1727 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1728 |
@command(b'perf::rawfiles|perfrawfiles', formatteropts) |
27095
aaf4e2d77148
contrib/perf: name functions to match decorators
timeless <timeless@mozdev.org>
parents:
27072
diff
changeset
|
1729 |
def perfrawfiles(ui, repo, x, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1730 |
opts = _byteskwargs(opts) |
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1731 |
x = int(x) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1732 |
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
|
1733 |
cl = repo.changelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1734 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1735 |
def d(): |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1736 |
len(cl.read(x)[3]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1737 |
|
24349
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1738 |
timer(d) |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1739 |
fm.end() |
389693a245fa
perf: add methods for timing changeset file list reading
Matt Mackall <mpm@selenic.com>
parents:
23878
diff
changeset
|
1740 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1741 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1742 |
@command(b'perf::lookup|perflookup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1743 |
def perflookup(ui, repo, rev, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1744 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1745 |
timer, fm = gettimer(ui, opts) |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1746 |
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
|
1747 |
fm.end() |
7366
eb240755386d
Add contrib/perf.py for performance testing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1748 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1749 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1750 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1751 |
b'perf::linelogedits|perflinelogedits', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1752 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1753 |
(b'n', b'edits', 10000, b'number of edits'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1754 |
(b'', b'max-hunk-lines', 10, b'max lines in a hunk'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1755 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1756 |
norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1757 |
) |
39007
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1758 |
def perflinelogedits(ui, **opts): |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1759 |
from mercurial import linelog |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1760 |
|
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1761 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1762 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1763 |
edits = opts[b'edits'] |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1764 |
maxhunklines = opts[b'max_hunk_lines'] |
39007
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1765 |
|
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1766 |
maxb1 = 100000 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1767 |
random.seed(0) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1768 |
randint = random.randint |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1769 |
currentlines = 0 |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1770 |
arglist = [] |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
1771 |
for rev in _xrange(edits): |
39007
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1772 |
a1 = randint(0, currentlines) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1773 |
a2 = randint(a1, min(currentlines, a1 + maxhunklines)) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1774 |
b1 = randint(0, maxb1) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1775 |
b2 = randint(b1, b1 + maxhunklines) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1776 |
currentlines += (b2 - b1) - (a2 - a1) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1777 |
arglist.append((rev, a1, a2, b1, b2)) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1778 |
|
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1779 |
def d(): |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1780 |
ll = linelog.linelog() |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1781 |
for args in arglist: |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1782 |
ll.replacelines(*args) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1783 |
|
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1784 |
timer, fm = gettimer(ui, opts) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1785 |
timer(d) |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1786 |
fm.end() |
1601afbb573c
perf: add a command to benchmark linelog edits
Jun Wu <quark@fb.com>
parents:
38821
diff
changeset
|
1787 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1788 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1789 |
@command(b'perf::revrange|perfrevrange', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1790 |
def perfrevrange(ui, repo, *specs, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1791 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1792 |
timer, fm = gettimer(ui, opts) |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
1793 |
revrange = scmutil.revrange |
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
1794 |
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
|
1795 |
fm.end() |
16858
fdf99e0f60f3
perf: add a benchmark for revrange
Bryan O'Sullivan <bryano@fb.com>
parents:
16802
diff
changeset
|
1796 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1797 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1798 |
@command(b'perf::nodelookup|perfnodelookup', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1799 |
def perfnodelookup(ui, repo, rev, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1800 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1801 |
timer, fm = gettimer(ui, opts) |
16309 | 1802 |
import mercurial.revlog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1803 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1804 |
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:
37271
diff
changeset
|
1805 |
n = scmutil.revsingle(repo, rev).node() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1806 |
cl = mercurial.revlog.revlog(getsvfs(repo), b"00changelog.i") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1807 |
|
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1808 |
def d(): |
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1809 |
cl.rev(n) |
16785
1dc08dc63c09
perf: rework perfheads and perftags to clear caches
Bryan O'Sullivan <bryano@fb.com>
parents:
16689
diff
changeset
|
1810 |
clearcaches(cl) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1811 |
|
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1812 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1813 |
fm.end() |
16414
e8d37b78acfb
parsers: use base-16 trie for faster node->rev mapping
Bryan O'Sullivan <bryano@fb.com>
parents:
16403
diff
changeset
|
1814 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1815 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1816 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1817 |
b'perf::log|perflog', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1818 |
[(b'', b'rename', False, b'ask log to follow renames')] + formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1819 |
) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
1820 |
def perflog(ui, repo, rev=None, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1821 |
opts = _byteskwargs(opts) |
27306
bafb1235f505
perf: add optional rev for perflog and perftemplating
timeless <timeless@mozdev.org>
parents:
27305
diff
changeset
|
1822 |
if rev is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1823 |
rev = [] |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1824 |
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
|
1825 |
ui.pushbuffer() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1826 |
timer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1827 |
lambda: commands.log( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1828 |
ui, repo, rev=rev, date=b'', user=b'', copies=opts.get(b'rename') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1829 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1830 |
) |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
1831 |
ui.popbuffer() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1832 |
fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
1833 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1834 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1835 |
@command(b'perf::moonwalk|perfmoonwalk', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1836 |
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
|
1837 |
"""benchmark walking the changelog backwards |
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1838 |
|
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1839 |
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
|
1840 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1841 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1842 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1843 |
|
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1844 |
def moonwalk(): |
38819
a4d847cea6f8
perfmoonwalk: make work with filtered repo
Martin von Zweigbergk <martinvonz@google.com>
parents:
38695
diff
changeset
|
1845 |
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
|
1846 |
ctx = repo[i] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1847 |
ctx.branch() # read changelog data (in addition to the index) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1848 |
|
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1849 |
timer(moonwalk) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1850 |
fm.end() |
20178
74aea4be8e78
perf: add perfmoonwalk command to walk the changelog backwards
Brodie Rao <brodie@sf.io>
parents:
20032
diff
changeset
|
1851 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1852 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1853 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1854 |
b'perf::templating|perftemplating', |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1855 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1856 |
(b'r', b'rev', [], b'revisions to run the template on'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1857 |
] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
1858 |
+ formatteropts, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1859 |
) |
38270
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38269
diff
changeset
|
1860 |
def perftemplating(ui, repo, testedtemplate=None, **opts): |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38269
diff
changeset
|
1861 |
"""test the rendering time of a given template""" |
38269
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1862 |
if makelogtemplater is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1863 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1864 |
b"perftemplating not available with this Mercurial", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1865 |
hint=b"use 4.3 or later", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1866 |
) |
38269
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1867 |
|
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1868 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
1869 |
|
38267
71d59b487d0c
perftemplating: drop usage of buffer
Boris Feld <boris.feld@octobus.net>
parents:
38266
diff
changeset
|
1870 |
nullui = ui.copy() |
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43551
diff
changeset
|
1871 |
nullui.fout = open(os.devnull, 'wb') |
38267
71d59b487d0c
perftemplating: drop usage of buffer
Boris Feld <boris.feld@octobus.net>
parents:
38266
diff
changeset
|
1872 |
nullui.disablepager() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1873 |
revs = opts.get(b'rev') |
38269
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1874 |
if not revs: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
1875 |
revs = [b'all()'] |
38269
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1876 |
revs = list(scmutil.revrange(repo, revs)) |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1877 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1878 |
defaulttemplate = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1879 |
b'{date|shortdate} [{rev}:{node|short}]' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1880 |
b' {author|person}: {desc|firstline}\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1881 |
) |
38270
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38269
diff
changeset
|
1882 |
if testedtemplate is None: |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38269
diff
changeset
|
1883 |
testedtemplate = defaulttemplate |
ae6e02fcee24
perftemplating: allow to specify the template to test
Boris Feld <boris.feld@octobus.net>
parents:
38269
diff
changeset
|
1884 |
displayer = makelogtemplater(nullui, repo, testedtemplate) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1885 |
|
38266
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38265
diff
changeset
|
1886 |
def format(): |
38269
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1887 |
for r in revs: |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1888 |
ctx = repo[r] |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1889 |
displayer.show(ctx) |
a577a199983c
perftemplating: stop going through the log command
Boris Feld <boris.feld@octobus.net>
parents:
38268
diff
changeset
|
1890 |
displayer.flush(ctx) |
38266
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38265
diff
changeset
|
1891 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
1892 |
timer, fm = gettimer(ui, opts) |
38266
6b91815fcdce
perftemplating: move template formating into its own function
Boris Feld <boris.feld@octobus.net>
parents:
38265
diff
changeset
|
1893 |
timer(format) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
1894 |
fm.end() |
7872
f680a1bd679b
contrib: add perflog and perftemplating commands to perf extension
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7366
diff
changeset
|
1895 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1896 |
|
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1897 |
def _displaystats(ui, opts, entries, data): |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1898 |
# use a second formatter because the data are quite different, not sure |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1899 |
# how it flies with the templater. |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1900 |
fm = ui.formatter(b'perf-stats', opts) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1901 |
for key, title in entries: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1902 |
values = data[key] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1903 |
nbvalues = len(data) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1904 |
values.sort() |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1905 |
stats = { |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1906 |
'key': key, |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1907 |
'title': title, |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1908 |
'nbitems': len(values), |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1909 |
'min': values[0][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1910 |
'10%': values[(nbvalues * 10) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1911 |
'25%': values[(nbvalues * 25) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1912 |
'50%': values[(nbvalues * 50) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1913 |
'75%': values[(nbvalues * 75) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1914 |
'80%': values[(nbvalues * 80) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1915 |
'85%': values[(nbvalues * 85) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1916 |
'90%': values[(nbvalues * 90) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1917 |
'95%': values[(nbvalues * 95) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1918 |
'99%': values[(nbvalues * 99) // 100][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1919 |
'max': values[-1][0], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1920 |
} |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1921 |
fm.startitem() |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1922 |
fm.data(**stats) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1923 |
# make node pretty for the human output |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1924 |
fm.plain('### %s (%d items)\n' % (title, len(values))) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1925 |
lines = [ |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1926 |
'min', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1927 |
'10%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1928 |
'25%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1929 |
'50%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1930 |
'75%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1931 |
'80%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1932 |
'85%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1933 |
'90%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1934 |
'95%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1935 |
'99%', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1936 |
'max', |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1937 |
] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1938 |
for l in lines: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1939 |
fm.plain('%s: %s\n' % (l, stats[l])) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1940 |
fm.end() |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1941 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1942 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1943 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
1944 |
b'perf::helper-mergecopies|perfhelper-mergecopies', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1945 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1946 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1947 |
(b'r', b'revs', [], b'restrict search to these revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1948 |
(b'', b'timing', False, b'provides extra data (costly)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1949 |
(b'', b'stats', False, b'provides statistic about the measured data'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1950 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1951 |
) |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1952 |
def perfhelpermergecopies(ui, repo, revs=[], **opts): |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1953 |
"""find statistics about potential parameters for `perfmergecopies` |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1954 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1955 |
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:
42403
diff
changeset
|
1956 |
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:
42403
diff
changeset
|
1957 |
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:
42403
diff
changeset
|
1958 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1959 |
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:
42403
diff
changeset
|
1960 |
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:
42403
diff
changeset
|
1961 |
execution. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1962 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1963 |
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:
42403
diff
changeset
|
1964 |
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:
42403
diff
changeset
|
1965 |
approximation of which revision triplets are very costly. |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1966 |
""" |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1967 |
opts = _byteskwargs(opts) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1968 |
fm = ui.formatter(b'perf', opts) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1969 |
dotiming = opts[b'timing'] |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
1970 |
dostats = opts[b'stats'] |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1971 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1972 |
output_template = [ |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1973 |
("base", "%(base)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1974 |
("p1", "%(p1.node)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1975 |
("p2", "%(p2.node)12s"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1976 |
("p1.nb-revs", "%(p1.nbrevs)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1977 |
("p1.nb-files", "%(p1.nbmissingfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1978 |
("p1.renames", "%(p1.renamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1979 |
("p1.time", "%(p1.time)12.3f"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1980 |
("p2.nb-revs", "%(p2.nbrevs)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1981 |
("p2.nb-files", "%(p2.nbmissingfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1982 |
("p2.renames", "%(p2.renamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1983 |
("p2.time", "%(p2.time)12.3f"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1984 |
("renames", "%(nbrenamedfiles)12d"), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1985 |
("total.time", "%(time)12.3f"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1986 |
] |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1987 |
if not dotiming: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1988 |
output_template = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1989 |
i |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1990 |
for i in output_template |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1991 |
if not ('time' in i[0] or 'renames' in i[0]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
1992 |
] |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1993 |
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:
42403
diff
changeset
|
1994 |
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:
42403
diff
changeset
|
1995 |
header = ' '.join(['%12s'] * len(header_names)) + '\n' |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1996 |
fm.plain(header % tuple(header_names)) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1997 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1998 |
if not revs: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
1999 |
revs = ['all()'] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2000 |
revs = scmutil.revrange(repo, revs) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2001 |
|
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2002 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2003 |
alldata = { |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2004 |
'nbrevs': [], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2005 |
'nbmissingfiles': [], |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2006 |
} |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2007 |
if dotiming: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2008 |
alldata['parentnbrenames'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2009 |
alldata['totalnbrenames'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2010 |
alldata['parenttime'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2011 |
alldata['totaltime'] = [] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2012 |
|
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2013 |
roi = repo.revs('merge() and %ld', revs) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2014 |
for r in roi: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2015 |
ctx = repo[r] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2016 |
p1 = ctx.p1() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2017 |
p2 = ctx.p2() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2018 |
bases = repo.changelog._commonancestorsheads(p1.rev(), p2.rev()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2019 |
for b in bases: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2020 |
b = repo[b] |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2021 |
p1missing = copies._computeforwardmissing(b, p1) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2022 |
p2missing = copies._computeforwardmissing(b, p2) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2023 |
data = { |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2024 |
b'base': b.hex(), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2025 |
b'p1.node': p1.hex(), |
43161
9d57c2df7b5f
perf: fix `perfhelper-mergecopies` report of #changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43160
diff
changeset
|
2026 |
b'p1.nbrevs': len(repo.revs('only(%d, %d)', p1.rev(), b.rev())), |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2027 |
b'p1.nbmissingfiles': len(p1missing), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2028 |
b'p2.node': p2.hex(), |
43161
9d57c2df7b5f
perf: fix `perfhelper-mergecopies` report of #changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43160
diff
changeset
|
2029 |
b'p2.nbrevs': len(repo.revs('only(%d, %d)', p2.rev(), b.rev())), |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2030 |
b'p2.nbmissingfiles': len(p2missing), |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2031 |
} |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2032 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2033 |
if p1missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2034 |
alldata['nbrevs'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2035 |
(data['p1.nbrevs'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2036 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2037 |
alldata['nbmissingfiles'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2038 |
(data['p1.nbmissingfiles'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2039 |
) |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2040 |
if p2missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2041 |
alldata['nbrevs'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2042 |
(data['p2.nbrevs'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2043 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2044 |
alldata['nbmissingfiles'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2045 |
(data['p2.nbmissingfiles'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2046 |
) |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2047 |
if dotiming: |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2048 |
begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2049 |
mergedata = copies.mergecopies(repo, p1, p2, b) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2050 |
end = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2051 |
# 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:
42403
diff
changeset
|
2052 |
data['time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2053 |
# mergedata contains five dicts: "copy", "movewithdir", |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2054 |
# "diverge", "renamedelete" and "dirmove". |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2055 |
# 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:
42403
diff
changeset
|
2056 |
renames = len(mergedata[0]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2057 |
renames += len(mergedata[1]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2058 |
renames += len(mergedata[2]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2059 |
renames += len(mergedata[3]) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2060 |
data['nbrenamedfiles'] = renames |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2061 |
begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2062 |
p1renames = copies.pathcopies(b, p1) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2063 |
end = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2064 |
data['p1.time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2065 |
begin = util.timer() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2066 |
p2renames = copies.pathcopies(b, p2) |
43979
a2ad5aeedfdf
perf: fix the time measurement for pathcopies relative to p2
Matt Harbison <matt_harbison@yahoo.com>
parents:
43697
diff
changeset
|
2067 |
end = util.timer() |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2068 |
data['p2.time'] = end - begin |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2069 |
data['p1.renamedfiles'] = len(p1renames) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2070 |
data['p2.renamedfiles'] = len(p2renames) |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2071 |
|
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2072 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2073 |
if p1missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2074 |
alldata['parentnbrenames'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2075 |
(data['p1.renamedfiles'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2076 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2077 |
alldata['parenttime'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2078 |
(data['p1.time'], b.hex(), p1.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2079 |
) |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2080 |
if p2missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2081 |
alldata['parentnbrenames'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2082 |
(data['p2.renamedfiles'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2083 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2084 |
alldata['parenttime'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2085 |
(data['p2.time'], b.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2086 |
) |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2087 |
if p1missing or p2missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2088 |
alldata['totalnbrenames'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2089 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2090 |
data['nbrenamedfiles'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2091 |
b.hex(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2092 |
p1.hex(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2093 |
p2.hex(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2094 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2095 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2096 |
alldata['totaltime'].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2097 |
(data['time'], b.hex(), p1.hex(), p2.hex()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2098 |
) |
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2099 |
fm.startitem() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2100 |
fm.data(**data) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2101 |
# make node pretty for the human output |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2102 |
out = data.copy() |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2103 |
out['base'] = fm.hexfunc(b.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2104 |
out['p1.node'] = fm.hexfunc(p1.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2105 |
out['p2.node'] = fm.hexfunc(p2.node()) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2106 |
fm.plain(output % out) |
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2107 |
|
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2108 |
fm.end() |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2109 |
if dostats: |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2110 |
# use a second formatter because the data are quite different, not sure |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2111 |
# how it flies with the templater. |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2112 |
entries = [ |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2113 |
('nbrevs', 'number of revision covered'), |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2114 |
('nbmissingfiles', 'number of missing files at head'), |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2115 |
] |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2116 |
if dotiming: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2117 |
entries.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2118 |
('parentnbrenames', 'rename from one parent to base') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2119 |
) |
42945
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2120 |
entries.append(('totalnbrenames', 'total number of renames')) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2121 |
entries.append(('parenttime', 'time for one parent')) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2122 |
entries.append(('totaltime', 'time for both parents')) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2123 |
_displaystats(ui, opts, entries, alldata) |
3a1ad3aeb64a
perf: add a --stats argument to perfhelper-mergecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42801
diff
changeset
|
2124 |
|
42404
21c436a3a4e8
perf: add a `perfhelper-mergecopies` command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42403
diff
changeset
|
2125 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2126 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2127 |
b'perf::helper-pathcopies|perfhelper-pathcopies', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2128 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2129 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2130 |
(b'r', b'revs', [], b'restrict search to these revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2131 |
(b'', b'timing', False, b'provides extra data (costly)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2132 |
(b'', b'stats', False, b'provides statistic about the measured data'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2133 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2134 |
) |
40774
30d878cb102d
perf: rename `perfhelper-tracecopies` to `perfhelper-pathcopies`
Boris Feld <boris.feld@octobus.net>
parents:
40773
diff
changeset
|
2135 |
def perfhelperpathcopies(ui, repo, revs=[], **opts): |
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2136 |
"""find statistic about potential parameters for the `perftracecopies` |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2137 |
|
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2138 |
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:
40722
diff
changeset
|
2139 |
It report value for some of the parameters that impact copy tracing time. |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2140 |
|
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2141 |
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:
40760
diff
changeset
|
2142 |
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:
40760
diff
changeset
|
2143 |
execution. |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2144 |
|
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2145 |
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:
40760
diff
changeset
|
2146 |
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:
40760
diff
changeset
|
2147 |
approximation of which revision pairs are very costly. |
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2148 |
""" |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2149 |
opts = _byteskwargs(opts) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2150 |
fm = ui.formatter(b'perf', opts) |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2151 |
dotiming = opts[b'timing'] |
42946
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2152 |
dostats = opts[b'stats'] |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2153 |
|
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2154 |
if dotiming: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2155 |
header = '%12s %12s %12s %12s %12s %12s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2156 |
output = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2157 |
"%(source)12s %(destination)12s " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2158 |
"%(nbrevs)12d %(nbmissingfiles)12d " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2159 |
"%(nbrenamedfiles)12d %(time)18.5f\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2160 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2161 |
header_names = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2162 |
"source", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2163 |
"destination", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2164 |
"nb-revs", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2165 |
"nb-files", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2166 |
"nb-renames", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2167 |
"time", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2168 |
) |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2169 |
fm.plain(header % header_names) |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2170 |
else: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2171 |
header = '%12s %12s %12s %12s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2172 |
output = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2173 |
"%(source)12s %(destination)12s " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2174 |
"%(nbrevs)12d %(nbmissingfiles)12d\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2175 |
) |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2176 |
fm.plain(header % ("source", "destination", "nb-revs", "nb-files")) |
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2177 |
|
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2178 |
if not revs: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2179 |
revs = ['all()'] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2180 |
revs = scmutil.revrange(repo, revs) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2181 |
|
42946
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2182 |
if dostats: |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2183 |
alldata = { |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2184 |
'nbrevs': [], |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2185 |
'nbmissingfiles': [], |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2186 |
} |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2187 |
if dotiming: |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2188 |
alldata['nbrenames'] = [] |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2189 |
alldata['time'] = [] |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2190 |
|
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2191 |
roi = repo.revs('merge() and %ld', revs) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2192 |
for r in roi: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2193 |
ctx = repo[r] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2194 |
p1 = ctx.p1().rev() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2195 |
p2 = ctx.p2().rev() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2196 |
bases = repo.changelog._commonancestorsheads(p1, p2) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2197 |
for p in (p1, p2): |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2198 |
for b in bases: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2199 |
base = repo[b] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2200 |
parent = repo[p] |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2201 |
missing = copies._computeforwardmissing(base, parent) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2202 |
if not missing: |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2203 |
continue |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2204 |
data = { |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2205 |
b'source': base.hex(), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2206 |
b'destination': parent.hex(), |
43160
84a950007619
perf: fix `perfhelper-pathcopies` report of #changesets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43130
diff
changeset
|
2207 |
b'nbrevs': len(repo.revs('only(%d, %d)', p, b)), |
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2208 |
b'nbmissingfiles': len(missing), |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2209 |
} |
43005
bbf77341a956
perf: fix perfhelper-pathcopies without --stats
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42981
diff
changeset
|
2210 |
if dostats: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2211 |
alldata['nbrevs'].append( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2212 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2213 |
data['nbrevs'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2214 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2215 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2216 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2217 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2218 |
alldata['nbmissingfiles'].append( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2219 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2220 |
data['nbmissingfiles'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2221 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2222 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2223 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2224 |
) |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2225 |
if dotiming: |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2226 |
begin = util.timer() |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2227 |
renames = copies.pathcopies(base, parent) |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2228 |
end = util.timer() |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2229 |
# 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:
40760
diff
changeset
|
2230 |
data['time'] = end - begin |
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2231 |
data['nbrenamedfiles'] = len(renames) |
43005
bbf77341a956
perf: fix perfhelper-pathcopies without --stats
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42981
diff
changeset
|
2232 |
if dostats: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2233 |
alldata['time'].append( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2234 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2235 |
data['time'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2236 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2237 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2238 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2239 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2240 |
alldata['nbrenames'].append( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2241 |
( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2242 |
data['nbrenamedfiles'], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2243 |
base.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2244 |
parent.hex(), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
2245 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2246 |
) |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2247 |
fm.startitem() |
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2248 |
fm.data(**data) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2249 |
out = data.copy() |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2250 |
out['source'] = fm.hexfunc(base.node()) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2251 |
out['destination'] = fm.hexfunc(parent.node()) |
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2252 |
fm.plain(output % out) |
40765
36077a0f6f12
perf: add a `--timing` argument to `perfhelper-tracecopies`
Boris Feld <boris.feld@octobus.net>
parents:
40760
diff
changeset
|
2253 |
|
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2254 |
fm.end() |
42946
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2255 |
if dostats: |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2256 |
entries = [ |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2257 |
('nbrevs', 'number of revision covered'), |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2258 |
('nbmissingfiles', 'number of missing files at head'), |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2259 |
] |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2260 |
if dotiming: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2261 |
entries.append(('nbrenames', 'renamed files')) |
42946
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2262 |
entries.append(('time', 'time')) |
adac17faa72e
perf: add a --stats argument to perfhelper-pathcopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42945
diff
changeset
|
2263 |
_displaystats(ui, opts, entries, alldata) |
40730
a65fe13de84f
perf: add a new `perfhelper-tracecopies` command
Boris Feld <boris.feld@octobus.net>
parents:
40722
diff
changeset
|
2264 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2265 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2266 |
@command(b'perf::cca|perfcca', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2267 |
def perfcca(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2268 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2269 |
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
|
2270 |
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
|
2271 |
fm.end() |
16386
ccc173d0914e
perf: add case collision auditor perf
Matt Mackall <mpm@selenic.com>
parents:
16309
diff
changeset
|
2272 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2273 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2274 |
@command(b'perf::fncacheload|perffncacheload', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2275 |
def perffncacheload(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2276 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2277 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
2278 |
s = repo.store |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2279 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2280 |
def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2281 |
s.fncache._load() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2282 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2283 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2284 |
fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2285 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2286 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2287 |
@command(b'perf::fncachewrite|perffncachewrite', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2288 |
def perffncachewrite(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2289 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2290 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
2291 |
s = repo.store |
38695
2cdb82e8fb44
perffncachewrite: load fncache after lock is acquired
Boris Feld <boris.feld@octobus.net>
parents:
38694
diff
changeset
|
2292 |
lock = repo.lock() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2293 |
s.fncache._load() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2294 |
tr = repo.transaction(b'perffncachewrite') |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2295 |
tr.addbackup(b'fncache') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2296 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2297 |
def d(): |
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2298 |
s.fncache._dirty = True |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
2299 |
s.fncache.write(tr) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2300 |
|
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2301 |
timer(d) |
30069
98b9846a131e
perf: release lock after transaction in perffncachewrite
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30020
diff
changeset
|
2302 |
tr.close() |
27097
b3e24a9c5f9b
contrib/perf: fix perffncachewrite
timeless <timeless@mozdev.org>
parents:
27096
diff
changeset
|
2303 |
lock.release() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2304 |
fm.end() |
16403
efae1fea4bbd
perf: time fncache read and write performance
Bryan O'Sullivan <bryano@fb.com>
parents:
16386
diff
changeset
|
2305 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2306 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2307 |
@command(b'perf::fncacheencode|perffncacheencode', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2308 |
def perffncacheencode(ui, repo, **opts): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2309 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2310 |
timer, fm = gettimer(ui, opts) |
17780
769f66861eb8
perf: simply use repo.store for perffncache* commands
Adrian Buehlmann <adrian@cadifra.com>
parents:
17553
diff
changeset
|
2311 |
s = repo.store |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2312 |
s.fncache._load() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2313 |
|
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2314 |
def d(): |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2315 |
for p in s.fncache.entries: |
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2316 |
s.encode(p) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2317 |
|
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2318 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2319 |
fm.end() |
17553
5ab863922e0f
perf: add perffncacheencode
Adrian Buehlmann <adrian@cadifra.com>
parents:
17216
diff
changeset
|
2320 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2321 |
|
36774
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2322 |
def _bdiffworker(q, blocks, xdiff, ready, done): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2323 |
while not done.is_set(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2324 |
pair = q.get() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2325 |
while pair is not None: |
36774
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2326 |
if xdiff: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2327 |
mdiff.bdiff.xdiffblocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2328 |
elif blocks: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2329 |
mdiff.bdiff.blocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2330 |
else: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2331 |
mdiff.textdiff(*pair) |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2332 |
q.task_done() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2333 |
pair = q.get() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2334 |
q.task_done() # for the None one |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2335 |
with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2336 |
ready.wait() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2337 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2338 |
|
39346
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2339 |
def _manifestrevision(repo, mnode): |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2340 |
ml = repo.manifestlog |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2341 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2342 |
if util.safehasattr(ml, b'getstorage'): |
39346
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2343 |
store = ml.getstorage(b'') |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2344 |
else: |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2345 |
store = ml._revlog |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2346 |
|
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2347 |
return store.revision(mnode) |
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2348 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2349 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2350 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2351 |
b'perf::bdiff|perfbdiff', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2352 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2353 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2354 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2355 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2356 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2357 |
b'count', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2358 |
1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2359 |
b'number of revisions to test (when using --startrev)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2360 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2361 |
(b'', b'alldata', False, b'test bdiffs for all associated revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2362 |
(b'', b'threads', 0, b'number of thread to use (disable with 0)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2363 |
(b'', b'blocks', False, b'test computing diffs into blocks'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2364 |
(b'', b'xdiff', False, b'use xdiff algorithm'), |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2365 |
], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2366 |
b'-c|-m|FILE REV', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2367 |
) |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2368 |
def perfbdiff(ui, repo, file_, rev=None, count=None, threads=0, **opts): |
30346
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30345
diff
changeset
|
2369 |
"""benchmark a bdiff between revisions |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30345
diff
changeset
|
2370 |
|
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30345
diff
changeset
|
2371 |
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:
30345
diff
changeset
|
2372 |
|
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30345
diff
changeset
|
2373 |
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:
30345
diff
changeset
|
2374 |
revisions starting at the specified revision. |
30347
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2375 |
|
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2376 |
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:
30346
diff
changeset
|
2377 |
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:
30346
diff
changeset
|
2378 |
and filelogs). |
30346
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30345
diff
changeset
|
2379 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2380 |
opts = _byteskwargs(opts) |
36774
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2381 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2382 |
if opts[b'xdiff'] and not opts[b'blocks']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2383 |
raise error.CommandError(b'perfbdiff', b'--xdiff requires --blocks') |
36774
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2384 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2385 |
if opts[b'alldata']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2386 |
opts[b'changelog'] = True |
30347
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2387 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2388 |
if opts.get(b'changelog') or opts.get(b'manifest'): |
30320
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2389 |
file_, rev = None, file_ |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2390 |
elif rev is None: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2391 |
raise error.CommandError(b'perfbdiff', b'invalid arguments') |
30320
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2392 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2393 |
blocks = opts[b'blocks'] |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2394 |
xdiff = opts[b'xdiff'] |
30345
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30320
diff
changeset
|
2395 |
textpairs = [] |
7d91a085ebe6
perf: prepare to handle multiple pairs in perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30320
diff
changeset
|
2396 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2397 |
r = cmdutil.openrevlog(repo, b'perfbdiff', file_, opts) |
30320
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2398 |
|
30346
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30345
diff
changeset
|
2399 |
startrev = r.rev(r.lookup(rev)) |
7ddc8f8d7712
perf: support bdiffing multiple revisions in a single revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30345
diff
changeset
|
2400 |
for rev in range(startrev, min(startrev + count, len(r) - 1)): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2401 |
if opts[b'alldata']: |
30347
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2402 |
# Load revisions associated with changeset. |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2403 |
ctx = repo[rev] |
39346
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2404 |
mtext = _manifestrevision(repo, ctx.manifestnode()) |
30347
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2405 |
for pctx in ctx.parents(): |
39346
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2406 |
pman = _manifestrevision(repo, pctx.manifestnode()) |
30347
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2407 |
textpairs.append((pman, mtext)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2408 |
|
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2409 |
# Load filelog revisions by iterating manifest delta. |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2410 |
man = ctx.manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2411 |
pman = ctx.p1().manifest() |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2412 |
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:
30346
diff
changeset
|
2413 |
fctx = repo.file(filename) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2414 |
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:
30346
diff
changeset
|
2415 |
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:
30346
diff
changeset
|
2416 |
textpairs.append((f1, f2)) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2417 |
else: |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2418 |
dp = r.deltaparent(rev) |
6ecad4b73569
perf: support measuring bdiff for all changeset related data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30346
diff
changeset
|
2419 |
textpairs.append((r.revision(dp), r.revision(rev))) |
30320
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2420 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2421 |
withthreads = threads > 0 |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2422 |
if not withthreads: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2423 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2424 |
def d(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2425 |
for pair in textpairs: |
36774
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2426 |
if xdiff: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2427 |
mdiff.bdiff.xdiffblocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2428 |
elif blocks: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2429 |
mdiff.bdiff.blocks(*pair) |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2430 |
else: |
d382344c69aa
perf: teach perfbdiff to call blocks() and to use xdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36393
diff
changeset
|
2431 |
mdiff.textdiff(*pair) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2432 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2433 |
else: |
37890
8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37355
diff
changeset
|
2434 |
q = queue() |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
2435 |
for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2436 |
q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2437 |
ready = threading.Condition() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2438 |
done = threading.Event() |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
2439 |
for i in _xrange(threads): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2440 |
threading.Thread( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2441 |
target=_bdiffworker, args=(q, blocks, xdiff, ready, done) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2442 |
).start() |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2443 |
q.join() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2444 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2445 |
def d(): |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2446 |
for pair in textpairs: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2447 |
q.put(pair) |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
2448 |
for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2449 |
q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2450 |
with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2451 |
ready.notify_all() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2452 |
q.join() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2453 |
|
30320
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2454 |
timer, fm = gettimer(ui, opts) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2455 |
timer(d) |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2456 |
fm.end() |
c8fa7ad1ff90
perf: add perfbdiff
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30219
diff
changeset
|
2457 |
|
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2458 |
if withthreads: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2459 |
done.set() |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
2460 |
for i in _xrange(threads): |
35599
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2461 |
q.put(None) |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2462 |
with ready: |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2463 |
ready.notify_all() |
af25237be091
perf: add threading capability to perfbdiff
Boris Feld <boris.feld@octobus.net>
parents:
35137
diff
changeset
|
2464 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2465 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2466 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2467 |
b'perf::unidiff|perfunidiff', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2468 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2469 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2470 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2471 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2472 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2473 |
b'count', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2474 |
1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2475 |
b'number of revisions to test (when using --startrev)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2476 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2477 |
(b'', b'alldata', False, b'test unidiffs for all associated revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2478 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2479 |
b'-c|-m|FILE REV', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2480 |
) |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2481 |
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
|
2482 |
"""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
|
2483 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2484 |
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
|
2485 |
of the texts. |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2486 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2487 |
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
|
2488 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2489 |
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
|
2490 |
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
|
2491 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2492 |
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
|
2493 |
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
|
2494 |
and filelogs). |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2495 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2496 |
opts = _byteskwargs(opts) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2497 |
if opts[b'alldata']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2498 |
opts[b'changelog'] = True |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2499 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2500 |
if opts.get(b'changelog') or opts.get(b'manifest'): |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2501 |
file_, rev = None, file_ |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2502 |
elif rev is None: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2503 |
raise error.CommandError(b'perfunidiff', b'invalid arguments') |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2504 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2505 |
textpairs = [] |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2506 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2507 |
r = cmdutil.openrevlog(repo, b'perfunidiff', file_, opts) |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2508 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2509 |
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
|
2510 |
for rev in range(startrev, min(startrev + count, len(r) - 1)): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2511 |
if opts[b'alldata']: |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2512 |
# 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
|
2513 |
ctx = repo[rev] |
39346
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2514 |
mtext = _manifestrevision(repo, ctx.manifestnode()) |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2515 |
for pctx in ctx.parents(): |
39346
862d23bc5749
perf: add function for obtaining manifest revision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39345
diff
changeset
|
2516 |
pman = _manifestrevision(repo, pctx.manifestnode()) |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2517 |
textpairs.append((pman, mtext)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2518 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2519 |
# 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
|
2520 |
man = ctx.manifest() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2521 |
pman = ctx.p1().manifest() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2522 |
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
|
2523 |
fctx = repo.file(filename) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2524 |
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
|
2525 |
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
|
2526 |
textpairs.append((f1, f2)) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2527 |
else: |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2528 |
dp = r.deltaparent(rev) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2529 |
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
|
2530 |
|
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2531 |
def d(): |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2532 |
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
|
2533 |
# 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
|
2534 |
headerlines, hunks = mdiff.unidiff( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2535 |
left, b'', right, b'', b'left', b'right', binary=False |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2536 |
) |
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2537 |
# 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
|
2538 |
b'\n'.join(headerlines) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2539 |
b''.join(sum((list(hlines) for hrange, hlines in hunks), [])) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2540 |
|
35901
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2541 |
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
|
2542 |
timer(d) |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2543 |
fm.end() |
ed939545edd0
perf: add a perfunidiff command for benchmarking unified diff speed
Augie Fackler <augie@google.com>
parents:
35602
diff
changeset
|
2544 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2545 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2546 |
@command(b'perf::diffwd|perfdiffwd', formatteropts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2547 |
def perfdiffwd(ui, repo, **opts): |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2548 |
"""Profile diff of working directory changes""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2549 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
2550 |
timer, fm = gettimer(ui, opts) |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2551 |
options = { |
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
2552 |
'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
|
2553 |
'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
|
2554 |
'B': 'ignore_blank_lines', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2555 |
} |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2556 |
|
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
2557 |
for diffopt in ('', 'w', 'b', 'B', 'wB'): |
44470
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44307
diff
changeset
|
2558 |
opts = {options[c]: b'1' for c in diffopt} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2559 |
|
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2560 |
def d(): |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2561 |
ui.pushbuffer() |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2562 |
commands.diff(ui, repo, **opts) |
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2563 |
ui.popbuffer() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2564 |
|
40214
b456b2e0ad9f
py3: make test-contrib-perf.t work on python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40145
diff
changeset
|
2565 |
diffopt = diffopt.encode('ascii') |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2566 |
title = b'diffopts: %s' % (diffopt and (b'-' + diffopt) or b'none') |
40718
20d2fd6036ed
perf: explicitly pass title as a keyword argument in `perfdiffwd`
Boris Feld <boris.feld@octobus.net>
parents:
40605
diff
changeset
|
2567 |
timer(d, title=title) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2568 |
fm.end() |
9826
d768614578dd
contrib/perf: profile diff of working directory changes
Patrick Mezard <pmezard@gmail.com>
parents:
9146
diff
changeset
|
2569 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2570 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2571 |
@command( |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2572 |
b'perf::revlogindex|perfrevlogindex', |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2573 |
revlogopts + formatteropts, |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2574 |
b'-c|-m|FILE', |
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2575 |
) |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2576 |
def perfrevlogindex(ui, repo, file_=None, **opts): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2577 |
"""Benchmark operations against a revlog index. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2578 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2579 |
This tests constructing a revlog instance, reading index data, |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2580 |
parsing index data, and performing various operations related to |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2581 |
index data. |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2582 |
""" |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2583 |
|
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2584 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2585 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2586 |
rl = cmdutil.openrevlog(repo, b'perfrevlogindex', file_, opts) |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2587 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2588 |
opener = getattr(rl, 'opener') # trick linter |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2589 |
indexfile = rl.indexfile |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2590 |
data = opener.read(indexfile) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2591 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2592 |
header = struct.unpack(b'>I', data[0:4])[0] |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2593 |
version = header & 0xFFFF |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2594 |
if version == 1: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2595 |
revlogio = revlog.revlogio() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2596 |
inline = header & (1 << 16) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2597 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2598 |
raise error.Abort(b'unsupported revlog version: %d' % version) |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2599 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2600 |
rllen = len(rl) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2601 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2602 |
node0 = rl.node(0) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2603 |
node25 = rl.node(rllen // 4) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2604 |
node50 = rl.node(rllen // 2) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2605 |
node75 = rl.node(rllen // 4 * 3) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2606 |
node100 = rl.node(rllen - 1) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2607 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2608 |
allrevs = range(rllen) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2609 |
allrevsrev = list(reversed(allrevs)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2610 |
allnodes = [rl.node(rev) for rev in range(rllen)] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2611 |
allnodesrev = list(reversed(allnodes)) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2612 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2613 |
def constructor(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2614 |
revlog.revlog(opener, indexfile) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2615 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2616 |
def read(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2617 |
with opener(indexfile) as fh: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2618 |
fh.read() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2619 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2620 |
def parseindex(): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2621 |
revlogio.parseindex(data, inline) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2622 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2623 |
def getentry(revornode): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2624 |
index = revlogio.parseindex(data, inline)[0] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2625 |
index[revornode] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2626 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2627 |
def getentries(revs, count=1): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2628 |
index = revlogio.parseindex(data, inline)[0] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2629 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2630 |
for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2631 |
for rev in revs: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2632 |
index[rev] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2633 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2634 |
def resolvenode(node): |
43620
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2635 |
index = revlogio.parseindex(data, inline)[0] |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2636 |
rev = getattr(index, 'rev', None) |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2637 |
if rev is None: |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2638 |
nodemap = getattr( |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2639 |
revlogio.parseindex(data, inline)[0], 'nodemap', None |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2640 |
) |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2641 |
# This only works for the C code. |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2642 |
if nodemap is None: |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2643 |
return |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2644 |
rev = nodemap.__getitem__ |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2645 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2646 |
try: |
43620
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2647 |
rev(node) |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2648 |
except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2649 |
pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2650 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2651 |
def resolvenodes(nodes, count=1): |
43620
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2652 |
index = revlogio.parseindex(data, inline)[0] |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2653 |
rev = getattr(index, 'rev', None) |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2654 |
if rev is None: |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2655 |
nodemap = getattr( |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2656 |
revlogio.parseindex(data, inline)[0], 'nodemap', None |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2657 |
) |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2658 |
# This only works for the C code. |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2659 |
if nodemap is None: |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2660 |
return |
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2661 |
rev = nodemap.__getitem__ |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2662 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2663 |
for i in range(count): |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2664 |
for node in nodes: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2665 |
try: |
43620
c314177eb9bb
perf: make `perfrevlogindex` use the new `index.rev` api if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43619
diff
changeset
|
2666 |
rev(node) |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2667 |
except error.RevlogError: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2668 |
pass |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2669 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2670 |
benches = [ |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2671 |
(constructor, b'revlog constructor'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2672 |
(read, b'read'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2673 |
(parseindex, b'create index object'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2674 |
(lambda: getentry(0), b'retrieve index entry for rev 0'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2675 |
(lambda: resolvenode(b'a' * 20), b'look up missing node'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2676 |
(lambda: resolvenode(node0), b'look up node at rev 0'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2677 |
(lambda: resolvenode(node25), b'look up node at 1/4 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2678 |
(lambda: resolvenode(node50), b'look up node at 1/2 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2679 |
(lambda: resolvenode(node75), b'look up node at 3/4 len'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2680 |
(lambda: resolvenode(node100), b'look up node at tip'), |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2681 |
# 2x variation is to measure caching impact. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2682 |
(lambda: resolvenodes(allnodes), b'look up all nodes (forward)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2683 |
(lambda: resolvenodes(allnodes, 2), b'look up all nodes 2x (forward)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2684 |
(lambda: resolvenodes(allnodesrev), b'look up all nodes (reverse)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2685 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2686 |
lambda: resolvenodes(allnodesrev, 2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2687 |
b'look up all nodes 2x (reverse)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2688 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2689 |
(lambda: getentries(allrevs), b'retrieve all index entries (forward)'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2690 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2691 |
lambda: getentries(allrevs, 2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2692 |
b'retrieve all index entries 2x (forward)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2693 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2694 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2695 |
lambda: getentries(allrevsrev), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2696 |
b'retrieve all index entries (reverse)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2697 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2698 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2699 |
lambda: getentries(allrevsrev, 2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2700 |
b'retrieve all index entries 2x (reverse)', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2701 |
), |
32565
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2702 |
] |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2703 |
|
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2704 |
for fn, title in benches: |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2705 |
timer, fm = gettimer(ui, opts) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2706 |
timer(fn, title=title) |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2707 |
fm.end() |
e4f514627514
perf: benchmark command for revlog indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32564
diff
changeset
|
2708 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2709 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2710 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2711 |
b'perf::revlogrevisions|perfrevlogrevisions', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2712 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2713 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2714 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2715 |
(b'd', b'dist', 100, b'distance between the revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2716 |
(b's', b'startrev', 0, b'revision to start reading at'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2717 |
(b'', b'reverse', False, b'read in reverse'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2718 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2719 |
b'-c|-m|FILE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2720 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2721 |
def perfrevlogrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2722 |
ui, repo, file_=None, startrev=0, reverse=False, **opts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2723 |
): |
27492
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
2724 |
"""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
|
2725 |
|
ac549d7fbc2b
perf: use standard arguments for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27472
diff
changeset
|
2726 |
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
|
2727 |
the specified revlog. |
27493
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
2728 |
|
14b0930105da
perf: make start revision configurable for perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27492
diff
changeset
|
2729 |
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
|
2730 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2731 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
2732 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2733 |
rl = cmdutil.openrevlog(repo, b'perfrevlogrevisions', file_, opts) |
32272
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32271
diff
changeset
|
2734 |
rllen = getlen(ui)(rl) |
30019
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2735 |
|
40143
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
2736 |
if startrev < 0: |
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
2737 |
startrev = rllen + startrev |
d5d28d360a19
pref: support negative indexing in perfrevlogrevisions
Boris Feld <boris.feld@octobus.net>
parents:
40142
diff
changeset
|
2738 |
|
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
2739 |
def d(): |
32272
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32271
diff
changeset
|
2740 |
rl.clearcaches() |
30019
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2741 |
|
32264
6b582f9b6e5e
perf: don't clobber startrev variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32246
diff
changeset
|
2742 |
beginrev = startrev |
32272
4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32271
diff
changeset
|
2743 |
endrev = rllen |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
2744 |
dist = opts[b'dist'] |
30019
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2745 |
|
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2746 |
if reverse: |
40587
cbd251d479bb
perf: fix perfrevlogrevisions --reverse
Boris Feld <boris.feld@octobus.net>
parents:
40581
diff
changeset
|
2747 |
beginrev, endrev = endrev - 1, beginrev - 1 |
30019
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2748 |
dist = -1 * dist |
973cf6c3de30
perf: add --reverse to perfrevlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29567
diff
changeset
|
2749 |
|
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
2750 |
for x in _xrange(beginrev, endrev, dist): |
32337
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32272
diff
changeset
|
2751 |
# Old revisions don't support passing int. |
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32272
diff
changeset
|
2752 |
n = rl.node(x) |
d7efaf6275a7
perf: always pass node to revlog.revision()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32272
diff
changeset
|
2753 |
rl.revision(n) |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
2754 |
|
32265
c68c400d0a2d
perf: move gettimer() call
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32264
diff
changeset
|
2755 |
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
|
2756 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
2757 |
fm.end() |
11694
bf49d48e4602
perf: add perfrevlog function to check performance of revlog
Pradeepkumar Gayam <in3xes@gmail.com>
parents:
10493
diff
changeset
|
2758 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2759 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2760 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
2761 |
b'perf::revlogwrite|perfrevlogwrite', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2762 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2763 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2764 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2765 |
(b's', b'startrev', 1000, b'revision to start writing at'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2766 |
(b'', b'stoprev', -1, b'last revision to write'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2767 |
(b'', b'count', 3, b'number of passes to perform'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2768 |
(b'', b'details', False, b'print timing for every revisions tested'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2769 |
(b'', b'source', b'full', b'the kind of data feed in the revlog'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2770 |
(b'', b'lazydeltabase', True, b'try the provided delta first'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2771 |
(b'', b'clear-caches', True, b'clear revlog cache between calls'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2772 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2773 |
b'-c|-m|FILE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2774 |
) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2775 |
def perfrevlogwrite(ui, repo, file_=None, startrev=1000, stoprev=-1, **opts): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2776 |
"""Benchmark writing a series of revisions to a revlog. |
40600
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2777 |
|
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2778 |
Possible source values are: |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2779 |
* `full`: add from a full text (default). |
40601
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40600
diff
changeset
|
2780 |
* `parent-1`: add from a delta to the first parent |
40602
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2781 |
* `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:
40601
diff
changeset
|
2782 |
(use a delta from the first parent otherwise) |
40603
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2783 |
* `parent-smallest`: add from the smallest delta (either p1 or p2) |
40604
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40603
diff
changeset
|
2784 |
* `storage`: add from the existing precomputed deltas |
42477
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2785 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2786 |
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:
42476
diff
changeset
|
2787 |
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:
42476
diff
changeset
|
2788 |
apply to it: |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2789 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2790 |
* ``pre-run``: disabled |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2791 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2792 |
* ``profile-benchmark``: disabled |
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2793 |
|
74e2f4b609f6
perf: clarify some of the custom behavior of `perfrevlogwrite`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42476
diff
changeset
|
2794 |
* ``run-limits``: disabled use --count instead |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2795 |
""" |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2796 |
opts = _byteskwargs(opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2797 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2798 |
rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2799 |
rllen = getlen(ui)(rl) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2800 |
if startrev < 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2801 |
startrev = rllen + startrev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2802 |
if stoprev < 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2803 |
stoprev = rllen + stoprev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2804 |
|
40605
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40604
diff
changeset
|
2805 |
lazydeltabase = opts['lazydeltabase'] |
40600
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2806 |
source = opts['source'] |
41012
e88ced97151d
perfrevlogwrite: fix a typo in the option name
Boris Feld <boris.feld@octobus.net>
parents:
40990
diff
changeset
|
2807 |
clearcaches = opts['clear_caches'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2808 |
validsource = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2809 |
b'full', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2810 |
b'parent-1', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2811 |
b'parent-2', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2812 |
b'parent-smallest', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2813 |
b'storage', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2814 |
) |
40600
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2815 |
if source not in validsource: |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2816 |
raise error.Abort('invalid source type: %s' % source) |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2817 |
|
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2818 |
### actually gather results |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2819 |
count = opts['count'] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2820 |
if count <= 0: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2821 |
raise error.Abort('invalide run count: %d' % count) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2822 |
allresults = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2823 |
for c in range(count): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2824 |
timing = _timeonewrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2825 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2826 |
rl, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2827 |
source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2828 |
startrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2829 |
stoprev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2830 |
c + 1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2831 |
lazydeltabase=lazydeltabase, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2832 |
clearcaches=clearcaches, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2833 |
) |
40600
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2834 |
allresults.append(timing) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2835 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2836 |
### consolidate the results in a single list |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2837 |
results = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2838 |
for idx, (rev, t) in enumerate(allresults[0]): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2839 |
ts = [t] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2840 |
for other in allresults[1:]: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2841 |
orev, ot = other[idx] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2842 |
assert orev == rev |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2843 |
ts.append(ot) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2844 |
results.append((rev, ts)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2845 |
resultcount = len(results) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2846 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2847 |
### Compute and display relevant statistics |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2848 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2849 |
# get a formatter |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2850 |
fm = ui.formatter(b'perf', opts) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2851 |
displayall = ui.configbool(b"perf", b"all-timing", False) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2852 |
|
40598
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40597
diff
changeset
|
2853 |
# print individual details if requested |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40597
diff
changeset
|
2854 |
if opts['details']: |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40597
diff
changeset
|
2855 |
for idx, item in enumerate(results, 1): |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40597
diff
changeset
|
2856 |
rev, data = item |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40597
diff
changeset
|
2857 |
title = 'revisions #%d of %d, rev %d' % (idx, resultcount, rev) |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40597
diff
changeset
|
2858 |
formatone(fm, data, title=title, displayall=displayall) |
4dd7edeb3da9
perf: offer full details in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40597
diff
changeset
|
2859 |
|
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2860 |
# sorts results by median time |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2861 |
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:
40587
diff
changeset
|
2862 |
# list of (name, index) to display) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2863 |
relevants = [ |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2864 |
("min", 0), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2865 |
("10%", resultcount * 10 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2866 |
("25%", resultcount * 25 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2867 |
("50%", resultcount * 70 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2868 |
("75%", resultcount * 75 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2869 |
("90%", resultcount * 90 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2870 |
("95%", resultcount * 95 // 100), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2871 |
("99%", resultcount * 99 // 100), |
40969
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40961
diff
changeset
|
2872 |
("99.9%", resultcount * 999 // 1000), |
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40961
diff
changeset
|
2873 |
("99.99%", resultcount * 9999 // 10000), |
74ee5ff1e81c
perf: report more of the higher range in perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40961
diff
changeset
|
2874 |
("99.999%", resultcount * 99999 // 100000), |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2875 |
("max", -1), |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2876 |
] |
40599
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40598
diff
changeset
|
2877 |
if not ui.quiet: |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40598
diff
changeset
|
2878 |
for name, idx in relevants: |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40598
diff
changeset
|
2879 |
data = results[idx] |
c63081cd3902
perf: only display the total time for perfrevlogwrite if quiet
Boris Feld <boris.feld@octobus.net>
parents:
40598
diff
changeset
|
2880 |
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:
40598
diff
changeset
|
2881 |
formatone(fm, data[1], title=title, displayall=displayall) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2882 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2883 |
# 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:
40587
diff
changeset
|
2884 |
# for now |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2885 |
totaltime = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2886 |
for item in allresults: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2887 |
totaltime.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2888 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2889 |
sum(x[1][0] for x in item), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2890 |
sum(x[1][1] for x in item), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2891 |
sum(x[1][2] for x in item), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2892 |
) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2893 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2894 |
formatone( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2895 |
fm, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2896 |
totaltime, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2897 |
title="total time (%d revs)" % resultcount, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2898 |
displayall=displayall, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2899 |
) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2900 |
fm.end() |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2901 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2902 |
|
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2903 |
class _faketr(object): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2904 |
def add(s, x, y, z=None): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2905 |
return None |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2906 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2907 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2908 |
def _timeonewrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2909 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2910 |
orig, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2911 |
source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2912 |
startrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2913 |
stoprev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2914 |
runidx=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2915 |
lazydeltabase=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2916 |
clearcaches=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2917 |
): |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2918 |
timings = [] |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2919 |
tr = _faketr() |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2920 |
with _temprevlog(ui, orig, startrev) as dest: |
40605
4756a33d0d31
perf: add a lazydeltabase option to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40604
diff
changeset
|
2921 |
dest._lazydeltabase = lazydeltabase |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2922 |
revs = list(orig.revs(startrev, stoprev)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2923 |
total = len(revs) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2924 |
topic = 'adding' |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2925 |
if runidx is not None: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2926 |
topic += ' (run #%d)' % runidx |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2927 |
# Support both old and new progress API |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2928 |
if util.safehasattr(ui, 'makeprogress'): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2929 |
progress = ui.makeprogress(topic, unit='revs', total=total) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2930 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2931 |
def updateprogress(pos): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2932 |
progress.update(pos) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2933 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2934 |
def completeprogress(): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2935 |
progress.complete() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2936 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2937 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2938 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2939 |
def updateprogress(pos): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2940 |
ui.progress(topic, pos, unit='revs', total=total) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2941 |
|
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2942 |
def completeprogress(): |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2943 |
ui.progress(topic, None, unit='revs', total=total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2944 |
|
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2945 |
for idx, rev in enumerate(revs): |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2946 |
updateprogress(idx) |
40600
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2947 |
addargs, addkwargs = _getrevisionseed(orig, rev, tr, source) |
40990
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40969
diff
changeset
|
2948 |
if clearcaches: |
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40969
diff
changeset
|
2949 |
dest.index.clearcaches() |
21a9cace4bbf
perfrevflogwrite: clear revlog cache between each write
Boris Feld <boris.feld@octobus.net>
parents:
40969
diff
changeset
|
2950 |
dest.clearcaches() |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2951 |
with timeone() as r: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2952 |
dest.addrawrevision(*addargs, **addkwargs) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2953 |
timings.append((rev, r[0])) |
41156
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2954 |
updateprogress(total) |
f36fd52dae8f
perfrevlogwrite: use progress helper on modern hg
Martin von Zweigbergk <martinvonz@google.com>
parents:
41012
diff
changeset
|
2955 |
completeprogress() |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2956 |
return timings |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2957 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2958 |
|
40600
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2959 |
def _getrevisionseed(orig, rev, tr, source): |
40602
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2960 |
from mercurial.node import nullid |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2961 |
|
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2962 |
linkrev = orig.linkrev(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2963 |
node = orig.node(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2964 |
p1, p2 = orig.parents(node) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2965 |
flags = orig.flags(rev) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2966 |
cachedelta = None |
40600
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2967 |
text = None |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2968 |
|
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2969 |
if source == b'full': |
631011ff6771
perf: add the notion of "source" to perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40599
diff
changeset
|
2970 |
text = orig.revision(rev) |
40601
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40600
diff
changeset
|
2971 |
elif source == b'parent-1': |
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40600
diff
changeset
|
2972 |
baserev = orig.rev(p1) |
6c2357029364
perf: add `parent-1` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40600
diff
changeset
|
2973 |
cachedelta = (baserev, orig.revdiff(p1, rev)) |
40602
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2974 |
elif source == b'parent-2': |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2975 |
parent = p2 |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2976 |
if p2 == nullid: |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2977 |
parent = p1 |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2978 |
baserev = orig.rev(parent) |
b5b3dd4e40c3
perf: add `parent-2` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40601
diff
changeset
|
2979 |
cachedelta = (baserev, orig.revdiff(parent, rev)) |
40603
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2980 |
elif source == b'parent-smallest': |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2981 |
p1diff = orig.revdiff(p1, rev) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2982 |
parent = p1 |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2983 |
diff = p1diff |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2984 |
if p2 != nullid: |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2985 |
p2diff = orig.revdiff(p2, rev) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2986 |
if len(p1diff) > len(p2diff): |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2987 |
parent = p2 |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2988 |
diff = p2diff |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2989 |
baserev = orig.rev(parent) |
e14d44772fb3
perf: add `parent-smallest` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40602
diff
changeset
|
2990 |
cachedelta = (baserev, diff) |
40604
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40603
diff
changeset
|
2991 |
elif source == b'storage': |
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40603
diff
changeset
|
2992 |
baserev = orig.deltaparent(rev) |
355ae096faef
perf: add `storage` as possible source for perfrevlogwrite
Boris Feld <boris.feld@octobus.net>
parents:
40603
diff
changeset
|
2993 |
cachedelta = (baserev, orig.revdiff(orig.node(baserev), rev)) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
2994 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2995 |
return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2996 |
(text, tr, linkrev, p1, p2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2997 |
{'node': node, 'flags': flags, 'cachedelta': cachedelta}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2998 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
2999 |
|
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3000 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3001 |
@contextlib.contextmanager |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3002 |
def _temprevlog(ui, orig, truncaterev): |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3003 |
from mercurial import vfs as vfsmod |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3004 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3005 |
if orig._inline: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3006 |
raise error.Abort('not supporting inline revlog (yet)') |
42478
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42477
diff
changeset
|
3007 |
revlogkwargs = {} |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42477
diff
changeset
|
3008 |
k = 'upperboundcomp' |
bc4373babd04
revlog: add the option to track the expected compression upper bound
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42477
diff
changeset
|
3009 |
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:
42477
diff
changeset
|
3010 |
revlogkwargs[k] = getattr(orig, k) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3011 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3012 |
origindexpath = orig.opener.join(orig.indexfile) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3013 |
origdatapath = orig.opener.join(orig.datafile) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3014 |
indexname = 'revlog.i' |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3015 |
dataname = 'revlog.d' |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3016 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3017 |
tmpdir = tempfile.mkdtemp(prefix='tmp-hgperf-') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3018 |
try: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3019 |
# copy the data file in a temporary directory |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3020 |
ui.debug('copying data in %s\n' % tmpdir) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3021 |
destindexpath = os.path.join(tmpdir, 'revlog.i') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3022 |
destdatapath = os.path.join(tmpdir, 'revlog.d') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3023 |
shutil.copyfile(origindexpath, destindexpath) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3024 |
shutil.copyfile(origdatapath, destdatapath) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3025 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3026 |
# remove the data we want to add again |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3027 |
ui.debug('truncating data to be rewritten\n') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3028 |
with open(destindexpath, 'ab') as index: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3029 |
index.seek(0) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3030 |
index.truncate(truncaterev * orig._io.size) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3031 |
with open(destdatapath, 'ab') as data: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3032 |
data.seek(0) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3033 |
data.truncate(orig.start(truncaterev)) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3034 |
|
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3035 |
# instantiate a new revlog from the temporary copy |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3036 |
ui.debug('truncating adding to be rewritten\n') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3037 |
vfs = vfsmod.vfs(tmpdir) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3038 |
vfs.options = getattr(orig.opener, 'options', None) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3039 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3040 |
dest = revlog.revlog( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3041 |
vfs, indexfile=indexname, datafile=dataname, **revlogkwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3042 |
) |
40597
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3043 |
if dest._inline: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3044 |
raise error.Abort('not supporting inline revlog (yet)') |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3045 |
# make sure internals are initialized |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3046 |
dest.revision(len(dest) - 1) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3047 |
yield dest |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3048 |
del dest, vfs |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3049 |
finally: |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3050 |
shutil.rmtree(tmpdir, True) |
164b2e77f9a5
perf: introduce a perfrevlogwrite command
Boris Feld <boris.feld@octobus.net>
parents:
40587
diff
changeset
|
3051 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3052 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3053 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3054 |
b'perf::revlogchunks|perfrevlogchunks', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3055 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3056 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3057 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3058 |
(b'e', b'engines', b'', b'compression engines to use'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3059 |
(b's', b'startrev', 0, b'revision to start at'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3060 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3061 |
b'-c|-m|FILE', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3062 |
) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3063 |
def perfrevlogchunks(ui, repo, file_=None, engines=None, startrev=0, **opts): |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3064 |
"""Benchmark operations on revlog chunks. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3065 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3066 |
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:
30435
diff
changeset
|
3067 |
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:
30435
diff
changeset
|
3068 |
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:
30435
diff
changeset
|
3069 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3070 |
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:
30435
diff
changeset
|
3071 |
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:
30435
diff
changeset
|
3072 |
For measurements of higher-level operations like resolving revisions, |
32564
7236facefd4f
perf: rename perfrevlog to perfrevlogrevisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32501
diff
changeset
|
3073 |
see ``perfrevlogrevisions`` and ``perfrevlogrevision``. |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3074 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3075 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3076 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3077 |
rl = cmdutil.openrevlog(repo, b'perfrevlogchunks', file_, opts) |
32269
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3078 |
|
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3079 |
# _chunkraw was renamed to _getsegmentforrevs. |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3080 |
try: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3081 |
segmentforrevs = rl._getsegmentforrevs |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3082 |
except AttributeError: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3083 |
segmentforrevs = rl._chunkraw |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3084 |
|
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3085 |
# Verify engines argument. |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3086 |
if engines: |
44470
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44307
diff
changeset
|
3087 |
engines = {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
|
3088 |
for engine in engines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3089 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3090 |
util.compressionengines[engine] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3091 |
except KeyError: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3092 |
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
|
3093 |
else: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3094 |
engines = [] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3095 |
for e in util.compengines: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3096 |
engine = util.compengines[e] |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3097 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3098 |
if engine.available(): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3099 |
engine.revlogcompressor().compress(b'dummy') |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3100 |
engines.append(e) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3101 |
except NotImplementedError: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3102 |
pass |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3103 |
|
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3104 |
revs = list(rl.revs(startrev, len(rl) - 1)) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3105 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3106 |
def rlfh(rl): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3107 |
if rl._inline: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3108 |
return getsvfs(repo)(rl.indexfile) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3109 |
else: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3110 |
return getsvfs(repo)(rl.datafile) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3111 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3112 |
def doread(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3113 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3114 |
for rev in revs: |
32268
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32265
diff
changeset
|
3115 |
segmentforrevs(rev, rev) |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3116 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3117 |
def doreadcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3118 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3119 |
fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3120 |
for rev in revs: |
32268
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32265
diff
changeset
|
3121 |
segmentforrevs(rev, rev, df=fh) |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3122 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3123 |
def doreadbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3124 |
rl.clearcaches() |
32268
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32265
diff
changeset
|
3125 |
segmentforrevs(revs[0], revs[-1]) |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3126 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3127 |
def doreadbatchcachedfh(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3128 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3129 |
fh = rlfh(rl) |
32268
112ba1c7d65d
perf: store reference to revlog._chunkraw in a local variable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32265
diff
changeset
|
3130 |
segmentforrevs(revs[0], revs[-1], df=fh) |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3131 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3132 |
def dochunk(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3133 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3134 |
fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3135 |
for rev in revs: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3136 |
rl._chunk(rev, df=fh) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3137 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3138 |
chunks = [None] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3139 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3140 |
def dochunkbatch(): |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3141 |
rl.clearcaches() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3142 |
fh = rlfh(rl) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3143 |
# Save chunks as a side-effect. |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3144 |
chunks[0] = rl._chunks(revs, df=fh) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3145 |
|
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3146 |
def docompress(compressor): |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3147 |
rl.clearcaches() |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3148 |
|
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3149 |
try: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3150 |
# Swap in the requested compression engine. |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3151 |
oldcompressor = rl._compressor |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3152 |
rl._compressor = compressor |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3153 |
for chunk in chunks[0]: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3154 |
rl.compress(chunk) |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3155 |
finally: |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3156 |
rl._compressor = oldcompressor |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3157 |
|
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3158 |
benches = [ |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3159 |
(lambda: doread(), b'read'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3160 |
(lambda: doreadcachedfh(), b'read w/ reused fd'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3161 |
(lambda: doreadbatch(), b'read batch'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3162 |
(lambda: doreadbatchcachedfh(), b'read batch w/ reused fd'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3163 |
(lambda: dochunk(), b'chunk'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3164 |
(lambda: dochunkbatch(), b'chunk batch'), |
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3165 |
] |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3166 |
|
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3167 |
for engine in sorted(engines): |
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3168 |
compressor = util.compengines[engine].revlogcompressor() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3169 |
benches.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3170 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3171 |
functools.partial(docompress, compressor), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3172 |
b'compress w/ %s' % engine, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3173 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3174 |
) |
30796
168ef0a4eb3b
perf: support multiple compression engines in perfrevlogchunks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30793
diff
changeset
|
3175 |
|
30460
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3176 |
for fn, title in benches: |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3177 |
timer, fm = gettimer(ui, opts) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3178 |
timer(fn, title=title) |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3179 |
fm.end() |
94ca0e13d1fc
perf: add command for measuring revlog chunk operations
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30435
diff
changeset
|
3180 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3181 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3182 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3183 |
b'perf::revlogrevision|perfrevlogrevision', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3184 |
revlogopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3185 |
+ formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3186 |
+ [(b'', b'cache', False, b'use caches instead of clearing')], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3187 |
b'-c|-m|FILE REV', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3188 |
) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3189 |
def perfrevlogrevision(ui, repo, file_, rev=None, cache=None, **opts): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3190 |
"""Benchmark obtaining a revlog revision. |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3191 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3192 |
Obtaining a revlog revision consists of roughly the following steps: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3193 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3194 |
1. Compute the delta chain |
40581
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3195 |
2. Slice the delta chain if applicable |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3196 |
3. Obtain the raw chunks for that delta chain |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3197 |
4. Decompress each raw chunk |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3198 |
5. Apply binary patches to obtain fulltext |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3199 |
6. Verify hash of fulltext |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3200 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3201 |
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
|
3202 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3203 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3204 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3205 |
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
|
3206 |
file_, rev = None, file_ |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3207 |
elif rev is None: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3208 |
raise error.CommandError(b'perfrevlogrevision', b'invalid arguments') |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3209 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3210 |
r = cmdutil.openrevlog(repo, b'perfrevlogrevision', file_, opts) |
32269
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3211 |
|
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3212 |
# _chunkraw was renamed to _getsegmentforrevs. |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3213 |
try: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3214 |
segmentforrevs = r._getsegmentforrevs |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3215 |
except AttributeError: |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3216 |
segmentforrevs = r._chunkraw |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32268
diff
changeset
|
3217 |
|
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3218 |
node = r.lookup(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3219 |
rev = r.rev(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3220 |
|
30914
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3221 |
def getrawchunks(data, chain): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3222 |
start = r.start |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3223 |
length = r.length |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3224 |
inline = r._inline |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3225 |
iosize = r._io.size |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3226 |
buffer = util.buffer |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3227 |
|
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3228 |
chunks = [] |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3229 |
ladd = chunks.append |
40580
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3230 |
for idx, item in enumerate(chain): |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3231 |
offset = start(item[0]) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3232 |
bits = data[idx] |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3233 |
for rev in item: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3234 |
chunkstart = start(rev) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3235 |
if inline: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3236 |
chunkstart += (rev + 1) * iosize |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3237 |
chunklength = length(rev) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3238 |
ladd(buffer(bits, chunkstart - offset, chunklength)) |
30914
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3239 |
|
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3240 |
return chunks |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3241 |
|
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3242 |
def dodeltachain(rev): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3243 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3244 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3245 |
r._deltachain(rev) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3246 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3247 |
def doread(chain): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3248 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3249 |
r.clearcaches() |
40580
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3250 |
for item in slicedchain: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3251 |
segmentforrevs(item[0], item[-1]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3252 |
|
40581
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3253 |
def doslice(r, chain, size): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3254 |
for s in slicechunk(r, chain, targetsize=size): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3255 |
pass |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3256 |
|
30914
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3257 |
def dorawchunks(data, chain): |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3258 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3259 |
r.clearcaches() |
30914
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3260 |
getrawchunks(data, chain) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3261 |
|
30914
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3262 |
def dodecompress(chunks): |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3263 |
decomp = r.decompress |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3264 |
for chunk in chunks: |
74cfc4357c64
perf: split obtaining chunks from decompression
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30796
diff
changeset
|
3265 |
decomp(chunk) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3266 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3267 |
def dopatch(text, bins): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3268 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3269 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3270 |
mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3271 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3272 |
def dohash(text): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3273 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3274 |
r.clearcaches() |
30589
be5b2098a817
revlog: merge hash checking subfunctions
Remi Chaintron <remi@fb.com>
parents:
30460
diff
changeset
|
3275 |
r.checkhash(text, node, rev=rev) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3276 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3277 |
def dorevision(): |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3278 |
if not cache: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3279 |
r.clearcaches() |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3280 |
r.revision(node) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3281 |
|
40580
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3282 |
try: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3283 |
from mercurial.revlogutils.deltas import slicechunk |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3284 |
except ImportError: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3285 |
slicechunk = getattr(revlog, '_slicechunk', None) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3286 |
|
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3287 |
size = r.length(rev) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3288 |
chain = r._deltachain(rev)[0] |
40580
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3289 |
if not getattr(r, '_withsparseread', False): |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3290 |
slicedchain = (chain,) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3291 |
else: |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3292 |
slicedchain = tuple(slicechunk(r, chain, targetsize=size)) |
914079ee3334
perf: teach perfrevlogrevision about sparse reading
Boris Feld <boris.feld@octobus.net>
parents:
40579
diff
changeset
|
3293 |
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:
40579
diff
changeset
|
3294 |
rawchunks = getrawchunks(data, slicedchain) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3295 |
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
|
3296 |
text = bytes(bins[0]) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3297 |
bins = bins[1:] |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3298 |
text = mdiff.patches(text, bins) |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3299 |
|
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3300 |
benches = [ |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3301 |
(lambda: dorevision(), b'full'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3302 |
(lambda: dodeltachain(rev), b'deltachain'), |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3303 |
(lambda: doread(chain), b'read'), |
40581
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3304 |
] |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3305 |
|
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3306 |
if getattr(r, '_withsparseread', False): |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3307 |
slicing = (lambda: doslice(r, chain, size), b'slice-sparse-chain') |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3308 |
benches.append(slicing) |
e6c8a0fd3db4
perf: measure slicing time in perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40580
diff
changeset
|
3309 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3310 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3311 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3312 |
(lambda: dorawchunks(data, slicedchain), b'rawchunks'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3313 |
(lambda: dodecompress(rawchunks), b'decompress'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3314 |
(lambda: dopatch(text, bins), b'patch'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3315 |
(lambda: dohash(text), b'hash'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3316 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3317 |
) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3318 |
|
40579
cf3bef7f162b
perf: use the same timer for all section of perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40349
diff
changeset
|
3319 |
timer, fm = gettimer(ui, opts) |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3320 |
for fn, title in benches: |
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3321 |
timer(fn, title=title) |
40579
cf3bef7f162b
perf: use the same timer for all section of perfrevlogrevision
Boris Feld <boris.feld@octobus.net>
parents:
40349
diff
changeset
|
3322 |
fm.end() |
27470
d394a1a3708a
perf: add perfrevlogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27467
diff
changeset
|
3323 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3324 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3325 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3326 |
b'perf::revset|perfrevset', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3327 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3328 |
(b'C', b'clear', False, b'clear volatile cache between each call.'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3329 |
(b'', b'contexts', False, b'obtain changectx for each revision'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3330 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3331 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3332 |
b"REVSET", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3333 |
) |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
3334 |
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
|
3335 |
"""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
|
3336 |
|
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18304
diff
changeset
|
3337 |
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
|
3338 |
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
|
3339 |
and obsolete related cache.""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3340 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3341 |
|
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
3342 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3343 |
|
18062
1471f5e83686
perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents:
18033
diff
changeset
|
3344 |
def d(): |
18239
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
3345 |
if clear: |
a95f1d619bb7
perftest: add an option to invalidate volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18238
diff
changeset
|
3346 |
repo.invalidatevolatilesets() |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
3347 |
if contexts: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3348 |
for ctx in repo.set(expr): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3349 |
pass |
27072
e18a9ceade3b
perf: support obtaining contexts from perfrevset
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27017
diff
changeset
|
3350 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3351 |
for r in repo.revs(expr): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3352 |
pass |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3353 |
|
18062
1471f5e83686
perf: add a command to measure revset performance
Siddharth Agarwal <sid0@fb.com>
parents:
18033
diff
changeset
|
3354 |
timer(d) |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
3355 |
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
|
3356 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3357 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3358 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3359 |
b'perf::volatilesets|perfvolatilesets', |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
3360 |
[ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
3361 |
(b'', b'clear-obsstore', False, b'drop obsstore between each call.'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
3362 |
] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3363 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3364 |
) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
3365 |
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
|
3366 |
"""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
|
3367 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
3368 |
Volatile set computes element related to filtering and obsolescence.""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3369 |
opts = _byteskwargs(opts) |
25494
e8eb3ecdaa0c
perf: support -T for every perf commands
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24607
diff
changeset
|
3370 |
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
|
3371 |
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
|
3372 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
3373 |
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
|
3374 |
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
|
3375 |
repo.invalidatevolatilesets() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3376 |
if opts[b'clear_obsstore']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3377 |
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
|
3378 |
obsolete.getrevs(repo, name) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3379 |
|
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
3380 |
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
|
3381 |
|
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
3382 |
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
|
3383 |
if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
3384 |
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
|
3385 |
|
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
3386 |
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
|
3387 |
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
|
3388 |
|
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
3389 |
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
|
3390 |
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
|
3391 |
repo.invalidatevolatilesets() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3392 |
if opts[b'clear_obsstore']: |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3393 |
clearfilecache(repo, b'obsstore') |
20205
d67a7758da6d
perf: fix perfvolatilesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
20178
diff
changeset
|
3394 |
repoview.filterrevs(repo, name) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3395 |
|
18240
a8318715d8bb
perftest: add a command to benchmark construction of volatile cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18239
diff
changeset
|
3396 |
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
|
3397 |
|
18241
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
3398 |
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
|
3399 |
if names: |
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
3400 |
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
|
3401 |
|
f5ed27c51995
perftest: allow selection of volatile set to benchmark
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18240
diff
changeset
|
3402 |
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
|
3403 |
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
|
3404 |
fm.end() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3405 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3406 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3407 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3408 |
b'perf::branchmap|perfbranchmap', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3409 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3410 |
(b'f', b'full', False, b'Includes build time of subset'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3411 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3412 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3413 |
b'clear-revbranch', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3414 |
False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3415 |
b'purge the revbranch cache between computation', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3416 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3417 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3418 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3419 |
) |
36393
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36392
diff
changeset
|
3420 |
def perfbranchmap(ui, repo, *filternames, **opts): |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3421 |
"""benchmark the update of a branchmap |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3422 |
|
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3423 |
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
|
3424 |
""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3425 |
opts = _byteskwargs(opts) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3426 |
full = opts.get(b"full", False) |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3427 |
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
|
3428 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3429 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3430 |
def getbranchmap(filtername): |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3431 |
"""generate a benchmark function for the filtername""" |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3432 |
if filtername is None: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3433 |
view = repo |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3434 |
else: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3435 |
view = repo.filtered(filtername) |
41626
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41579
diff
changeset
|
3436 |
if util.safehasattr(view._branchcaches, '_per_filter'): |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41579
diff
changeset
|
3437 |
filtered = view._branchcaches._per_filter |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41579
diff
changeset
|
3438 |
else: |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41579
diff
changeset
|
3439 |
# older versions |
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41579
diff
changeset
|
3440 |
filtered = view._branchcaches |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3441 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3442 |
def d(): |
32730
326c0e2c1a1d
perfbranchmap: add an option to purge the revbranch cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32565
diff
changeset
|
3443 |
if clear_revbranch: |
326c0e2c1a1d
perfbranchmap: add an option to purge the revbranch cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32565
diff
changeset
|
3444 |
repo.revbranchcache()._clear() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3445 |
if full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3446 |
view._branchcaches.clear() |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3447 |
else: |
41626
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41579
diff
changeset
|
3448 |
filtered.pop(filtername, None) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3449 |
view.branchmap() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3450 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3451 |
return d |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3452 |
|
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3453 |
# 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
|
3454 |
possiblefilters = set(repoview.filtertable) |
36393
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36392
diff
changeset
|
3455 |
if filternames: |
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36392
diff
changeset
|
3456 |
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
|
3457 |
subsettable = getbranchmapsubsettable() |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3458 |
allfilters = [] |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3459 |
while possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3460 |
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
|
3461 |
subset = subsettable.get(name) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3462 |
if subset not in possiblefilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3463 |
break |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3464 |
else: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3465 |
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
|
3466 |
allfilters.append(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3467 |
possiblefilters.remove(name) |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3468 |
|
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3469 |
# warm the cache |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3470 |
if not full: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3471 |
for name in allfilters: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3472 |
repo.filtered(name).branchmap() |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3473 |
if not filternames or b'unfiltered' in filternames: |
36393
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36392
diff
changeset
|
3474 |
# add unfiltered |
c25290b98190
perfbranchmap: allow to select the filter to benchmark
Boris Feld <boris.feld@octobus.net>
parents:
36392
diff
changeset
|
3475 |
allfilters.append(None) |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
3476 |
|
41579
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3477 |
if util.safehasattr(branchmap.branchcache, 'fromfile'): |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3478 |
branchcacheread = safeattrsetter(branchmap.branchcache, b'fromfile') |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3479 |
branchcacheread.set(classmethod(lambda *args: None)) |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3480 |
else: |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3481 |
# older versions |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3482 |
branchcacheread = safeattrsetter(branchmap, b'read') |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3483 |
branchcacheread.set(lambda *args: None) |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3484 |
branchcachewrite = safeattrsetter(branchmap.branchcache, b'write') |
41579
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3485 |
branchcachewrite.set(lambda *args: None) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3486 |
try: |
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3487 |
for name in allfilters: |
36392
df3f7f00a3fc
perfbranchmap: display 'unfiltered' for unfiltered performance
Boris Feld <boris.feld@octobus.net>
parents:
36216
diff
changeset
|
3488 |
printname = name |
df3f7f00a3fc
perfbranchmap: display 'unfiltered' for unfiltered performance
Boris Feld <boris.feld@octobus.net>
parents:
36216
diff
changeset
|
3489 |
if name is None: |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3490 |
printname = b'unfiltered' |
46255
cce05a6c271f
perf: don't turn byte to string when formatting perfbranchmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46196
diff
changeset
|
3491 |
timer(getbranchmap(name), title=printname) |
18304
9b6ae29d4801
perf: add perfbranchmap command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18241
diff
changeset
|
3492 |
finally: |
30145
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
3493 |
branchcacheread.restore() |
113aa6145020
perf: avoid actual writing branch cache out correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
3494 |
branchcachewrite.restore() |
23171
8afae1d5d108
perf: use a formatter for output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22780
diff
changeset
|
3495 |
fm.end() |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
3496 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3497 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3498 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3499 |
b'perf::branchmapupdate|perfbranchmapupdate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3500 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3501 |
(b'', b'base', [], b'subset of revision to start from'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3502 |
(b'', b'target', [], b'subset of revision to end with'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3503 |
(b'', b'clear-caches', False, b'clear cache between each runs'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3504 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3505 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3506 |
) |
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3507 |
def perfbranchmapupdate(ui, repo, base=(), target=(), **opts): |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3508 |
"""benchmark branchmap update from for <base> revs to <target> revs |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3509 |
|
40806
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3510 |
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:
40805
diff
changeset
|
3511 |
each update: |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3512 |
* the changelog instance and associated indexes |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3513 |
* the rev-branch-cache instance |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3514 |
|
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3515 |
Examples: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3516 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3517 |
# update for the one last revision |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3518 |
$ hg perfbranchmapupdate --base 'not tip' --target 'tip' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3519 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3520 |
$ update for change coming with a new branch |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3521 |
$ hg perfbranchmapupdate --base 'stable' --target 'default' |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3522 |
""" |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3523 |
from mercurial import branchmap |
40804
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3524 |
from mercurial import repoview |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3525 |
|
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3526 |
opts = _byteskwargs(opts) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3527 |
timer, fm = gettimer(ui, opts) |
40806
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3528 |
clearcaches = opts[b'clear_caches'] |
40804
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3529 |
unfi = repo.unfiltered() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3530 |
x = [None] # used to pass data between closure |
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3531 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3532 |
# 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:
40784
diff
changeset
|
3533 |
baserevs = list(scmutil.revrange(repo, base)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3534 |
targetrevs = list(scmutil.revrange(repo, target)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3535 |
if not baserevs: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3536 |
raise error.Abort(b'no revisions selected for --base') |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3537 |
if not targetrevs: |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3538 |
raise error.Abort(b'no revisions selected for --target') |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3539 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3540 |
# 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:
40784
diff
changeset
|
3541 |
targetrevs = list(set(baserevs) | set(targetrevs)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3542 |
targetrevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3543 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3544 |
cl = repo.changelog |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3545 |
allbaserevs = list(cl.ancestors(baserevs, inclusive=True)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3546 |
allbaserevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3547 |
alltargetrevs = frozenset(cl.ancestors(targetrevs, inclusive=True)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3548 |
|
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3549 |
newrevs = list(alltargetrevs.difference(allbaserevs)) |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3550 |
newrevs.sort() |
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3551 |
|
40804
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3552 |
allrevs = frozenset(unfi.changelog.revs()) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3553 |
basefilterrevs = frozenset(allrevs.difference(allbaserevs)) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3554 |
targetfilterrevs = frozenset(allrevs.difference(alltargetrevs)) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3555 |
|
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3556 |
def basefilter(repo, visibilityexceptions=None): |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3557 |
return basefilterrevs |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3558 |
|
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3559 |
def targetfilter(repo, visibilityexceptions=None): |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3560 |
return targetfilterrevs |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3561 |
|
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3562 |
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:
40784
diff
changeset
|
3563 |
ui.status(msg % (len(allbaserevs), len(newrevs))) |
40804
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3564 |
if targetfilterrevs: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3565 |
msg = b'(%d revisions still filtered)\n' |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3566 |
ui.status(msg % len(targetfilterrevs)) |
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3567 |
|
40804
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3568 |
try: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3569 |
repoview.filtertable[b'__perf_branchmap_update_base'] = basefilter |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3570 |
repoview.filtertable[b'__perf_branchmap_update_target'] = targetfilter |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3571 |
|
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3572 |
baserepo = repo.filtered(b'__perf_branchmap_update_base') |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3573 |
targetrepo = repo.filtered(b'__perf_branchmap_update_target') |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3574 |
|
40805
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3575 |
# try to find an existing branchmap to reuse |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3576 |
subsettable = getbranchmapsubsettable() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3577 |
candidatefilter = subsettable.get(None) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3578 |
while candidatefilter is not None: |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3579 |
candidatebm = repo.filtered(candidatefilter).branchmap() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3580 |
if candidatebm.validfor(baserepo): |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3581 |
filtered = repoview.filterrevs(repo, candidatefilter) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3582 |
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:
40804
diff
changeset
|
3583 |
base = candidatebm.copy() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3584 |
base.update(baserepo, missing) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3585 |
break |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3586 |
candidatefilter = subsettable.get(candidatefilter) |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3587 |
else: |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3588 |
# no suitable subset where found |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3589 |
base = branchmap.branchcache() |
58355a1de6b3
perf: start from an existing branchmap if possible
Boris Feld <boris.feld@octobus.net>
parents:
40804
diff
changeset
|
3590 |
base.update(baserepo, allbaserevs) |
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3591 |
|
40803
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40802
diff
changeset
|
3592 |
def setup(): |
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40802
diff
changeset
|
3593 |
x[0] = base.copy() |
40806
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3594 |
if clearcaches: |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3595 |
unfi._revbranchcache = None |
5cbb74999040
perf: add a `--clear-caches` to `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40805
diff
changeset
|
3596 |
clearchangelog(repo) |
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3597 |
|
40803
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40802
diff
changeset
|
3598 |
def bench(): |
40804
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3599 |
x[0].update(targetrepo, newrevs) |
40803
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40802
diff
changeset
|
3600 |
|
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40802
diff
changeset
|
3601 |
timer(bench, setup=setup) |
95f35c873463
perf: pre-indent some code in `perfbranchmapupdate`
Boris Feld <boris.feld@octobus.net>
parents:
40802
diff
changeset
|
3602 |
fm.end() |
40804
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3603 |
finally: |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3604 |
repoview.filtertable.pop(b'__perf_branchmap_update_base', None) |
b059388d976c
perf: rely on repoview for perfbranchmapupdate
Boris Feld <boris.feld@octobus.net>
parents:
40803
diff
changeset
|
3605 |
repoview.filtertable.pop(b'__perf_branchmap_update_target', None) |
40802
f723014677a5
perf: add a `perfbranchmapupdate` command
Boris Feld <boris.feld@octobus.net>
parents:
40784
diff
changeset
|
3606 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3607 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3608 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3609 |
b'perf::branchmapload|perfbranchmapload', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3610 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3611 |
(b'f', b'filter', b'', b'Specify repoview filter'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3612 |
(b'', b'list', False, b'List brachmap filter caches'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3613 |
(b'', b'clear-revlogs', False, b'refresh changelog and manifest'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3614 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3615 |
+ formatteropts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3616 |
) |
40738
94d76ddac40a
perf: update function name to match `perfbranchmapload` command
Boris Feld <boris.feld@octobus.net>
parents:
40737
diff
changeset
|
3617 |
def perfbranchmapload(ui, repo, filter=b'', list=False, **opts): |
39151
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3618 |
"""benchmark reading the branchmap""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3619 |
opts = _byteskwargs(opts) |
40741
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40740
diff
changeset
|
3620 |
clearrevlogs = opts[b'clear_revlogs'] |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3621 |
|
39151
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3622 |
if list: |
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3623 |
for name, kind, st in repo.cachevfs.readdir(stat=True): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3624 |
if name.startswith(b'branch2'): |
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3625 |
filtername = name.partition(b'-')[2] or b'unfiltered' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3626 |
ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3627 |
b'%s - %s\n' % (filtername, util.bytecount(st.st_size)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3628 |
) |
39151
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3629 |
return |
40759
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3630 |
if not filter: |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3631 |
filter = None |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3632 |
subsettable = getbranchmapsubsettable() |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3633 |
if filter is None: |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3634 |
repo = repo.unfiltered() |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3635 |
else: |
39151
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3636 |
repo = repoview.repoview(repo, filter) |
40758
578646b1e2b6
perf: prewarm the branchmap in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40752
diff
changeset
|
3637 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3638 |
repo.branchmap() # make sure we have a relevant, up to date branchmap |
40758
578646b1e2b6
perf: prewarm the branchmap in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40752
diff
changeset
|
3639 |
|
41579
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3640 |
try: |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3641 |
fromfile = branchmap.branchcache.fromfile |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3642 |
except AttributeError: |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3643 |
# older versions |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3644 |
fromfile = branchmap.read |
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3645 |
|
40759
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3646 |
currentfilter = filter |
39151
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3647 |
# try once without timer, the filter may not be cached |
41579
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3648 |
while fromfile(repo) is None: |
40759
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3649 |
currentfilter = subsettable.get(currentfilter) |
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3650 |
if currentfilter is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3651 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3652 |
b'No branchmap cached for %s repo' % (filter or b'unfiltered') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3653 |
) |
40759
0a3cc351d718
perf: fallback to subset if ondisk cache is missing in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40758
diff
changeset
|
3654 |
repo = repo.filtered(currentfilter) |
39151
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3655 |
timer, fm = gettimer(ui, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3656 |
|
40741
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40740
diff
changeset
|
3657 |
def setup(): |
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40740
diff
changeset
|
3658 |
if clearrevlogs: |
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40740
diff
changeset
|
3659 |
clearchangelog(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3660 |
|
40739
30f443d34a7d
perf: use an explicit function in perfbranchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40738
diff
changeset
|
3661 |
def bench(): |
41579
bf7fb97aecf1
branchmap: make branchcache responsible for reading
Martijn Pieters <mj@octobus.net>
parents:
41484
diff
changeset
|
3662 |
fromfile(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3663 |
|
40741
4240a1da4188
perf: add --clear-revlog flag to branchmapload
Boris Feld <boris.feld@octobus.net>
parents:
40740
diff
changeset
|
3664 |
timer(bench, setup=setup) |
39151
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3665 |
fm.end() |
222aba766015
perf: time loading branchmap caches
Martijn Pieters <mj@octobus.net>
parents:
39015
diff
changeset
|
3666 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3667 |
|
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3668 |
@command(b'perf::loadmarkers|perfloadmarkers') |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
3669 |
def perfloadmarkers(ui, repo): |
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
3670 |
"""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
|
3671 |
|
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
3672 |
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
|
3673 |
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
|
3674 |
svfs = getsvfs(repo) |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46733
diff
changeset
|
3675 |
timer(lambda: len(obsolete.obsstore(repo, svfs))) |
23485
ccb93e9affc1
perf: add a perfloadmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23171
diff
changeset
|
3676 |
fm.end() |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3677 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3678 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3679 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3680 |
b'perf::lrucachedict|perflrucachedict', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3681 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3682 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3683 |
(b'', b'costlimit', 0, b'maximum total cost of items in cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3684 |
(b'', b'mincost', 0, b'smallest cost of items in cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3685 |
(b'', b'maxcost', 100, b'maximum cost of items in cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3686 |
(b'', b'size', 4, b'size of cache'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3687 |
(b'', b'gets', 10000, b'number of key lookups'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3688 |
(b'', b'sets', 10000, b'number of key sets'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3689 |
(b'', b'mixed', 10000, b'number of mixed mode operations'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3690 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3691 |
b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3692 |
b'mixedgetfreq', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3693 |
50, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3694 |
b'frequency of get vs set ops in mixed mode', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3695 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3696 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3697 |
norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3698 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3699 |
def perflrucache( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3700 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3701 |
mincost=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3702 |
maxcost=100, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3703 |
costlimit=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3704 |
size=4, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3705 |
gets=10000, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3706 |
sets=10000, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3707 |
mixed=10000, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3708 |
mixedgetfreq=50, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3709 |
**opts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3710 |
): |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3711 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3712 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3713 |
def doinit(): |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
3714 |
for i in _xrange(10000): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3715 |
util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3716 |
|
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3717 |
costrange = list(range(mincost, maxcost + 1)) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3718 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3719 |
values = [] |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
3720 |
for i in _xrange(size): |
39828
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39827
diff
changeset
|
3721 |
values.append(random.randint(0, _maxint)) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3722 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3723 |
# 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
|
3724 |
# eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3725 |
getseq = [] |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
3726 |
for i in _xrange(gets): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3727 |
getseq.append(random.choice(values)) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3728 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3729 |
def dogets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3730 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3731 |
for v in values: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3732 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3733 |
for key in getseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3734 |
value = d[key] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3735 |
value # silence pyflakes warning |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3736 |
|
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3737 |
def dogetscost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3738 |
d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3739 |
for i, v in enumerate(values): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3740 |
d.insert(v, v, cost=costs[i]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3741 |
for key in getseq: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3742 |
try: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3743 |
value = d[key] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3744 |
value # silence pyflakes warning |
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3745 |
except KeyError: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3746 |
pass |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3747 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3748 |
# Set mode tests insertion speed with cache eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3749 |
setseq = [] |
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3750 |
costs = [] |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
3751 |
for i in _xrange(sets): |
39828
c4ab9fa81377
py3: work around the lack of sys.maxint in contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39827
diff
changeset
|
3752 |
setseq.append(random.randint(0, _maxint)) |
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3753 |
costs.append(random.choice(costrange)) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3754 |
|
39583
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39389
diff
changeset
|
3755 |
def doinserts(): |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39389
diff
changeset
|
3756 |
d = util.lrucachedict(size) |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39389
diff
changeset
|
3757 |
for v in setseq: |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39389
diff
changeset
|
3758 |
d.insert(v, v) |
ee087f0d7db5
util: allow lrucachedict to track cost of entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39389
diff
changeset
|
3759 |
|
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3760 |
def doinsertscost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3761 |
d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3762 |
for i, v in enumerate(setseq): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3763 |
d.insert(v, v, cost=costs[i]) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3764 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3765 |
def dosets(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3766 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3767 |
for v in setseq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3768 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3769 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3770 |
# Mixed mode randomly performs gets and sets with eviction. |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3771 |
mixedops = [] |
39827
86dbeb7c9a11
py3: switch contrib/perf from xrange to pycompat.xrange
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
3772 |
for i in _xrange(mixed): |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3773 |
r = random.randint(0, 100) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3774 |
if r < mixedgetfreq: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3775 |
op = 0 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3776 |
else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3777 |
op = 1 |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3778 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3779 |
mixedops.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3780 |
(op, random.randint(0, size * 2), random.choice(costrange)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3781 |
) |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3782 |
|
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3783 |
def domixed(): |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3784 |
d = util.lrucachedict(size) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3785 |
|
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3786 |
for op, v, cost in mixedops: |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3787 |
if op == 0: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3788 |
try: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3789 |
d[v] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3790 |
except KeyError: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3791 |
pass |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3792 |
else: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3793 |
d[v] = v |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3794 |
|
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3795 |
def domixedcost(): |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3796 |
d = util.lrucachedict(size, maxcost=costlimit) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3797 |
|
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3798 |
for op, v, cost in mixedops: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3799 |
if op == 0: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3800 |
try: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3801 |
d[v] |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3802 |
except KeyError: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3803 |
pass |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3804 |
else: |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3805 |
d.insert(v, v, cost=cost) |
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3806 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3807 |
benches = [ |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3808 |
(doinit, b'init'), |
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3809 |
] |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3810 |
|
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3811 |
if costlimit: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3812 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3813 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3814 |
(dogetscost, b'gets w/ cost limit'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3815 |
(doinsertscost, b'inserts w/ cost limit'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3816 |
(domixedcost, b'mixed w/ cost limit'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3817 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3818 |
) |
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3819 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3820 |
benches.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3821 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3822 |
(dogets, b'gets'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3823 |
(doinserts, b'inserts'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3824 |
(dosets, b'sets'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3825 |
(domixed, b'mixed'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3826 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3827 |
) |
39584
842cd0bdda75
util: teach lrucachedict to enforce a max total cost
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39583
diff
changeset
|
3828 |
|
27286
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3829 |
for fn, title in benches: |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3830 |
timer, fm = gettimer(ui, opts) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3831 |
timer(fn, title=title) |
528cf1a73ae5
perf: add perflrucachedict command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27100
diff
changeset
|
3832 |
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
|
3833 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3834 |
|
45016
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3835 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3836 |
b'perf::write|perfwrite', |
45016
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3837 |
formatteropts |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3838 |
+ [ |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3839 |
(b'', b'write-method', b'write', b'ui write method'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3840 |
(b'', b'nlines', 100, b'number of lines'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3841 |
(b'', b'nitems', 100, b'number of items (per line)'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3842 |
(b'', b'item', b'x', b'item that is written'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3843 |
(b'', b'batch-line', None, b'pass whole line to write method at once'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3844 |
(b'', b'flush-line', None, b'flush after each line'), |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3845 |
], |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3846 |
) |
30997
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30995
diff
changeset
|
3847 |
def perfwrite(ui, repo, **opts): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45635
diff
changeset
|
3848 |
"""microbenchmark ui.write (and others)""" |
39830
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3849 |
opts = _byteskwargs(opts) |
874712506b07
py3: apply byteskwargs to contrib/perf
Matt Harbison <matt_harbison@yahoo.com>
parents:
39829
diff
changeset
|
3850 |
|
45016
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3851 |
write = getattr(ui, _sysstr(opts[b'write_method'])) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3852 |
nlines = int(opts[b'nlines']) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3853 |
nitems = int(opts[b'nitems']) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3854 |
item = opts[b'item'] |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3855 |
batch_line = opts.get(b'batch_line') |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3856 |
flush_line = opts.get(b'flush_line') |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3857 |
|
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3858 |
if batch_line: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3859 |
line = item * nitems + b'\n' |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3860 |
|
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3861 |
def benchmark(): |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3862 |
for i in pycompat.xrange(nlines): |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3863 |
if batch_line: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3864 |
write(line) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3865 |
else: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3866 |
for i in pycompat.xrange(nitems): |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3867 |
write(item) |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3868 |
write(b'\n') |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3869 |
if flush_line: |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3870 |
ui.flush() |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3871 |
ui.flush() |
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3872 |
|
30997
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30995
diff
changeset
|
3873 |
timer, fm = gettimer(ui, opts) |
45016
c2df0bca0dfa
perf: make `hg perfwrite` more flexible
Manuel Jacob <me@manueljacob.de>
parents:
44470
diff
changeset
|
3874 |
timer(benchmark) |
30997
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30995
diff
changeset
|
3875 |
fm.end() |
5a9e4dc8e4fd
contrib: add a write microbenchmark to perf.py
Simon Farnsworth <simonfar@fb.com>
parents:
30995
diff
changeset
|
3876 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3877 |
|
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
|
3878 |
def uisetup(ui): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3879 |
if util.safehasattr(cmdutil, b'openrevlog') and not util.safehasattr( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3880 |
commands, b'debugrevlogopts' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3881 |
): |
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
|
3882 |
# 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
|
3883 |
# 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
|
3884 |
# 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
|
3885 |
# 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
|
3886 |
# 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
|
3887 |
def openrevlog(orig, repo, cmd, file_, opts): |
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3888 |
if opts.get(b'dir') and not util.safehasattr(repo, b'dirlog'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3889 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3890 |
b"This version doesn't support --dir option", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3891 |
hint=b"use 3.5 or later", |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3892 |
) |
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
|
3893 |
return orig(repo, cmd, file_, opts) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3894 |
|
39389
438f3932a432
contrib: byteify perf.py file
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39346
diff
changeset
|
3895 |
extensions.wrapfunction(cmdutil, b'openrevlog', openrevlog) |
40943
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3896 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3897 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3898 |
@command( |
46460
d8ad391e10f5
command-namespace: use `::` are the command separator
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46428
diff
changeset
|
3899 |
b'perf::progress|perfprogress', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3900 |
formatteropts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3901 |
+ [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3902 |
(b'', b'topic', b'topic', b'topic for progress messages'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3903 |
(b'c', b'total', 1000000, b'total value we are progressing to'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3904 |
], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3905 |
norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43005
diff
changeset
|
3906 |
) |
40943
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3907 |
def perfprogress(ui, topic=None, total=None, **opts): |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3908 |
"""printing of progress bars""" |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3909 |
opts = _byteskwargs(opts) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3910 |
|
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3911 |
timer, fm = gettimer(ui, opts) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3912 |
|
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3913 |
def doprogress(): |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3914 |
with ui.makeprogress(topic, total=total) as progress: |
42801
c00005975c91
perf: don't depend on pycompat for older Mercurial versions
Martin von Zweigbergk <martinvonz@google.com>
parents:
42800
diff
changeset
|
3915 |
for i in _xrange(total): |
40943
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3916 |
progress.increment() |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3917 |
|
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3918 |
timer(doprogress) |
008f3491dc53
perf: add perfprogress command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40818
diff
changeset
|
3919 |
fm.end() |