1#require test-repo
2
3Set vars:
4
5  $ . "$TESTDIR/helpers-testrepo.sh"
6  $ CONTRIBDIR="$TESTDIR/../contrib"
7
8Prepare repo:
9
10  $ hg init
11
12  $ echo this is file a > a
13  $ hg add a
14  $ hg commit -m first
15
16  $ echo adding to file a >> a
17  $ hg commit -m second
18
19  $ echo adding more to file a >> a
20  $ hg commit -m third
21
22  $ hg up -r 0
23  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
24  $ echo merge-this >> a
25  $ hg commit -m merge-able
26  created new head
27
28  $ hg up -r 2
29  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
30
31perfstatus
32
33  $ cat >> $HGRCPATH << EOF
34  > [extensions]
35  > perf=$CONTRIBDIR/perf.py
36  > [perf]
37  > presleep=0
38  > stub=on
39  > parentscount=1
40  > EOF
41  $ hg help -e perf
42  perf extension - helper extension to measure performance
43
44  Configurations
45  ==============
46
47  "perf"
48  ------
49
50  "all-timing"
51      When set, additional statistics will be reported for each benchmark: best,
52      worst, median average. If not set only the best timing is reported
53      (default: off).
54
55  "presleep"
56    number of second to wait before any group of runs (default: 1)
57
58  "pre-run"
59    number of run to perform before starting measurement.
60
61  "profile-benchmark"
62    Enable profiling for the benchmarked section. (The first iteration is
63    benchmarked)
64
65  "run-limits"
66    Control the number of runs each benchmark will perform. The option value
67    should be a list of '<time>-<numberofrun>' pairs. After each run the
68    conditions are considered in order with the following logic:
69
70        If benchmark has been running for <time> seconds, and we have performed
71        <numberofrun> iterations, stop the benchmark,
72
73    The default value is: '3.0-100, 10.0-3'
74
75  "stub"
76      When set, benchmarks will only be run once, useful for testing (default:
77      off)
78
79  list of commands:
80
81   perf::addremove
82                 (no help text available)
83   perf::ancestors
84                 (no help text available)
85   perf::ancestorset
86                 (no help text available)
87   perf::annotate
88                 (no help text available)
89   perf::bdiff   benchmark a bdiff between revisions
90   perf::bookmarks
91                 benchmark parsing bookmarks from disk to memory
92   perf::branchmap
93                 benchmark the update of a branchmap
94   perf::branchmapload
95                 benchmark reading the branchmap
96   perf::branchmapupdate
97                 benchmark branchmap update from for <base> revs to <target>
98                 revs
99   perf::bundleread
100                 Benchmark reading of bundle files.
101   perf::cca     (no help text available)
102   perf::changegroupchangelog
103                 Benchmark producing a changelog group for a changegroup.
104   perf::changeset
105                 (no help text available)
106   perf::ctxfiles
107                 (no help text available)
108   perf::diffwd  Profile diff of working directory changes
109   perf::dirfoldmap
110                 benchmap a 'dirstate._map.dirfoldmap.get()' request
111   perf::dirs    (no help text available)
112   perf::dirstate
113                 benchmap the time of various distate operations
114   perf::dirstatedirs
115                 benchmap a 'dirstate.hasdir' call from an empty 'dirs' cache
116   perf::dirstatefoldmap
117                 benchmap a 'dirstate._map.filefoldmap.get()' request
118   perf::dirstatewrite
119                 benchmap the time it take to write a dirstate on disk
120   perf::discovery
121                 benchmark discovery between local repo and the peer at given
122                 path
123   perf::fncacheencode
124                 (no help text available)
125   perf::fncacheload
126                 (no help text available)
127   perf::fncachewrite
128                 (no help text available)
129   perf::heads   benchmark the computation of a changelog heads
130   perf::helper-mergecopies
131                 find statistics about potential parameters for
132                 'perfmergecopies'
133   perf::helper-pathcopies
134                 find statistic about potential parameters for the
135                 'perftracecopies'
136   perf::ignore  benchmark operation related to computing ignore
137   perf::index   benchmark index creation time followed by a lookup
138   perf::linelogedits
139                 (no help text available)
140   perf::loadmarkers
141                 benchmark the time to parse the on-disk markers for a repo
142   perf::log     (no help text available)
143   perf::lookup  (no help text available)
144   perf::lrucachedict
145                 (no help text available)
146   perf::manifest
147                 benchmark the time to read a manifest from disk and return a
148                 usable
149   perf::mergecalculate
150                 (no help text available)
151   perf::mergecopies
152                 measure runtime of 'copies.mergecopies'
153   perf::moonwalk
154                 benchmark walking the changelog backwards
155   perf::nodelookup
156                 (no help text available)
157   perf::nodemap
158                 benchmark the time necessary to look up revision from a cold
159                 nodemap
160   perf::parents
161                 benchmark the time necessary to fetch one changeset's parents.
162   perf::pathcopies
163                 benchmark the copy tracing logic
164   perf::phases  benchmark phasesets computation
165   perf::phasesremote
166                 benchmark time needed to analyse phases of the remote server
167   perf::progress
168                 printing of progress bars
169   perf::rawfiles
170                 (no help text available)
171   perf::revlogchunks
172                 Benchmark operations on revlog chunks.
173   perf::revlogindex
174                 Benchmark operations against a revlog index.
175   perf::revlogrevision
176                 Benchmark obtaining a revlog revision.
177   perf::revlogrevisions
178                 Benchmark reading a series of revisions from a revlog.
179   perf::revlogwrite
180                 Benchmark writing a series of revisions to a revlog.
181   perf::revrange
182                 (no help text available)
183   perf::revset  benchmark the execution time of a revset
184   perf::startup
185                 (no help text available)
186   perf::status  benchmark the performance of a single status call
187   perf::tags    (no help text available)
188   perf::templating
189                 test the rendering time of a given template
190   perf::unidiff
191                 benchmark a unified diff between revisions
192   perf::volatilesets
193                 benchmark the computation of various volatile set
194   perf::walk    (no help text available)
195   perf::write   microbenchmark ui.write (and others)
196
197  (use 'hg help -v perf' to show built-in aliases and global options)
198
199  $ hg help perfaddremove
200  hg perf::addremove
201
202  aliases: perfaddremove
203
204  (no help text available)
205
206  options:
207
208   -T --template TEMPLATE display with template
209
210  (some details hidden, use --verbose to show complete help)
211
212  $ hg perfaddremove
213  $ hg perfancestors
214  $ hg perfancestorset 2
215  $ hg perfannotate a
216  $ hg perfbdiff -c 1
217  $ hg perfbdiff --alldata 1
218  $ hg perfunidiff -c 1
219  $ hg perfunidiff --alldata 1
220  $ hg perfbookmarks
221  $ hg perfbranchmap
222  $ hg perfbranchmapload
223  $ hg perfbranchmapupdate --base "not tip" --target "tip"
224  benchmark of branchmap with 3 revisions with 1 new ones
225  $ hg perfcca
226  $ hg perfchangegroupchangelog
227  $ hg perfchangegroupchangelog --cgversion 01
228  $ hg perfchangeset 2
229  $ hg perfctxfiles 2
230  $ hg perfdiffwd
231  $ hg perfdirfoldmap
232  $ hg perfdirs
233  $ hg perfdirstate
234  $ hg perfdirstate --contains
235  $ hg perfdirstate --iteration
236  $ hg perfdirstatedirs
237  $ hg perfdirstatefoldmap
238  $ hg perfdirstatewrite
239#if repofncache
240  $ hg perffncacheencode
241  $ hg perffncacheload
242  $ hg debugrebuildfncache
243  fncache already up to date
244  $ hg perffncachewrite
245  $ hg debugrebuildfncache
246  fncache already up to date
247#endif
248  $ hg perfheads
249  $ hg perfignore
250  $ hg perfindex
251  $ hg perflinelogedits -n 1
252  $ hg perfloadmarkers
253  $ hg perflog
254  $ hg perflookup 2
255  $ hg perflrucache
256  $ hg perfmanifest 2
257  $ hg perfmanifest -m 44fe2c8352bb3a478ffd7d8350bbc721920134d1
258  $ hg perfmanifest -m 44fe2c8352bb
259  abort: manifest revision must be integer or full node
260  [255]
261  $ hg perfmergecalculate -r 3
262  $ hg perfmoonwalk
263  $ hg perfnodelookup 2
264  $ hg perfpathcopies 1 2
265  $ hg perfprogress --total 1000
266  $ hg perfrawfiles 2
267  $ hg perfrevlogindex -c
268#if reporevlogstore
269  $ hg perfrevlogrevisions .hg/store/data/a.i
270#endif
271  $ hg perfrevlogrevision -m 0
272  $ hg perfrevlogchunks -c
273  $ hg perfrevrange
274  $ hg perfrevset 'all()'
275  $ hg perfstartup
276  $ hg perfstatus
277  $ hg perfstatus --dirstate
278  $ hg perftags
279  $ hg perftemplating
280  $ hg perfvolatilesets
281  $ hg perfwalk
282  $ hg perfparents
283  $ hg perfdiscovery -q .
284
285Test run control
286----------------
287
288Simple single entry
289
290  $ hg perfparents --config perf.stub=no --config perf.run-limits='0.000000001-15'
291  ! wall * comb * user * sys * (best of 15) (glob)
292
293Multiple entries
294
295  $ hg perfparents --config perf.stub=no --config perf.run-limits='500000-1, 0.000000001-5'
296  ! wall * comb * user * sys * (best of 5) (glob)
297
298error case are ignored
299
300  $ hg perfparents --config perf.stub=no --config perf.run-limits='500, 0.000000001-5'
301  malformatted run limit entry, missing "-": 500
302  ! wall * comb * user * sys * (best of 5) (glob)
303  $ hg perfparents --config perf.stub=no --config perf.run-limits='aaa-12, 0.000000001-5'
304  malformatted run limit entry, could not convert string to float: aaa: aaa-12 (no-py3 !)
305  malformatted run limit entry, could not convert string to float: 'aaa': aaa-12 (py3 !)
306  ! wall * comb * user * sys * (best of 5) (glob)
307  $ hg perfparents --config perf.stub=no --config perf.run-limits='12-aaaaaa, 0.000000001-5'
308  malformatted run limit entry, invalid literal for int() with base 10: 'aaaaaa': 12-aaaaaa
309  ! wall * comb * user * sys * (best of 5) (glob)
310
311test actual output
312------------------
313
314normal output:
315
316  $ hg perfheads --config perf.stub=no
317  ! wall * comb * user * sys * (best of *) (glob)
318
319detailed output:
320
321  $ hg perfheads --config perf.all-timing=yes --config perf.stub=no
322  ! wall * comb * user * sys * (best of *) (glob)
323  ! wall * comb * user * sys * (max of *) (glob)
324  ! wall * comb * user * sys * (avg of *) (glob)
325  ! wall * comb * user * sys * (median of *) (glob)
326
327test json output
328----------------
329
330normal output:
331
332  $ hg perfheads --template json --config perf.stub=no
333  [
334   {
335    "comb": *, (glob)
336    "count": *, (glob)
337    "sys": *, (glob)
338    "user": *, (glob)
339    "wall": * (glob)
340   }
341  ]
342
343detailed output:
344
345  $ hg perfheads --template json --config perf.all-timing=yes --config perf.stub=no
346  [
347   {
348    "avg.comb": *, (glob)
349    "avg.count": *, (glob)
350    "avg.sys": *, (glob)
351    "avg.user": *, (glob)
352    "avg.wall": *, (glob)
353    "comb": *, (glob)
354    "count": *, (glob)
355    "max.comb": *, (glob)
356    "max.count": *, (glob)
357    "max.sys": *, (glob)
358    "max.user": *, (glob)
359    "max.wall": *, (glob)
360    "median.comb": *, (glob)
361    "median.count": *, (glob)
362    "median.sys": *, (glob)
363    "median.user": *, (glob)
364    "median.wall": *, (glob)
365    "sys": *, (glob)
366    "user": *, (glob)
367    "wall": * (glob)
368   }
369  ]
370
371Test pre-run feature
372--------------------
373
374(perf discovery has some spurious output)
375
376  $ hg perfdiscovery . --config perf.stub=no --config perf.run-limits='0.000000001-1' --config perf.pre-run=0
377  ! wall * comb * user * sys * (best of 1) (glob)
378  searching for changes
379  $ hg perfdiscovery . --config perf.stub=no --config perf.run-limits='0.000000001-1' --config perf.pre-run=1
380  ! wall * comb * user * sys * (best of 1) (glob)
381  searching for changes
382  searching for changes
383  $ hg perfdiscovery . --config perf.stub=no --config perf.run-limits='0.000000001-1' --config perf.pre-run=3
384  ! wall * comb * user * sys * (best of 1) (glob)
385  searching for changes
386  searching for changes
387  searching for changes
388  searching for changes
389
390test  profile-benchmark option
391------------------------------
392
393Function to check that statprof ran
394  $ statprofran () {
395  >   egrep 'Sample count:|No samples recorded' > /dev/null
396  > }
397  $ hg perfdiscovery . --config perf.stub=no --config perf.run-limits='0.000000001-1' --config perf.profile-benchmark=yes 2>&1 | statprofran
398
399Check perf.py for historical portability
400----------------------------------------
401
402  $ cd "$TESTDIR/.."
403
404  $ (testrepohg files -r 1.2 glob:mercurial/*.c glob:mercurial/*.py;
405  >  testrepohg files -r tip glob:mercurial/*.c glob:mercurial/*.py) |
406  > "$TESTDIR"/check-perf-code.py contrib/perf.py
407  contrib/perf.py:\d+: (re)
408   >     from mercurial import (
409   import newer module separately in try clause for early Mercurial
410  contrib/perf.py:\d+: (re)
411   >     from mercurial import (
412   import newer module separately in try clause for early Mercurial
413  contrib/perf.py:\d+: (re)
414   >     origindexpath = orig.opener.join(indexfile)
415   use getvfs()/getsvfs() for early Mercurial
416  contrib/perf.py:\d+: (re)
417   >     origdatapath = orig.opener.join(datafile)
418   use getvfs()/getsvfs() for early Mercurial
419  contrib/perf.py:\d+: (re)
420   >         vfs = vfsmod.vfs(tmpdir)
421   use getvfs()/getsvfs() for early Mercurial
422  contrib/perf.py:\d+: (re)
423   >         vfs.options = getattr(orig.opener, 'options', None)
424   use getvfs()/getsvfs() for early Mercurial
425  [1]
426