tests/test-profile.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Wed, 07 Dec 2022 20:12:23 +0100
changeset 49887 e1953a34c110
parent 48967 42d2b31cee0b
child 50722 7e5be4a7cda7
permissions -rw-r--r--
bundle: emit full snapshot as is, without doing a redelta With the new `forced` delta-reused policy, it become important to be able to send full snapshot where full snapshot are needed. Otherwise, the fallback delta will simply be used on the client sideā€¦ creating monstrous delta chain, since revision that are meant as a reset of delta-chain chain becoming too complex are simply adding a new full delta-tree on the leaf of another one. In the `non-forced` cases, client process full snapshot from the bundle differently from deltas, so client will still try to convert the full snapshot into a delta if possible. So this will no lead to pathological storage explosion. I have considered making this configurable, but the impact seems limited enough that it does not seems to be worth it. Especially with the current sparse-revlog format that use "delta-tree" with multiple level snapshots, full snapshot are much less frequent and not that different from other intermediate snapshot that we are already sending over the wire anyway. CPU wise, this will help the bundling side a little as it will not need to reconstruct revisions and compute deltas. The unbundling side might save a tiny amount of CPU as it won't need to reconstruct the delta-base to reconstruct the revision full text. This only slightly visible in some of the benchmarks. And have no real impact on most of them. ### data-env-vars.name = pypy-2018-08-01-zstd-sparse-revlog # benchmark.name = perf-bundle # benchmark.variants.revs = last-40000 before: 11.467186 seconds just-emit-full: 11.190576 seconds (-2.41%) with-pull-force: 11.041091 seconds (-3.72%) # benchmark.name = perf-unbundle # benchmark.variants.revs = last-40000 before: 16.744862 just-emit-full:: 16.561036 seconds (-1.10%) with-pull-force: 16.389344 seconds (-2.12%) # benchmark.name = pull # benchmark.variants.revs = last-40000 before: 26.870569 just-emit-full: 26.391188 seconds (-1.78%) with-pull-force: 25.633184 seconds (-4.60%) Space wise (so network-wise) the impact is fairly small. When taking compression into account. Below are tests the size of `hg bundle --all` for a handful of benchmark repositories (with bzip, zstd compression and without it) This show a small increase in the bundle size, but nothing really significant except maybe for mozilla-try (+12%) that nobody really pulls large chunk of anyway. Mozilla-try is also the repository that benefit the most for not having to recompute deltas client size. ### mercurial: bzip-before: 26 406 342 bytes bzip-after: 26 691 543 bytes +1.08% zstd-before: 27 918 645 bytes zstd-after: 28 075 896 bytes +0.56% none-before: 98 675 601 bytes none-after: 100 411 237 bytes +1.76% ### pypy bzip-before: 201 295 752 bytes bzip-after: 209 780 282 bytes +4.21% zstd-before: 202 974 795 bytes zstd-after: 205 165 780 bytes +1.08% none-before: 871 070 261 bytes none-after: 993 595 057 bytes +14.07% ### netbeans bzip-before: 601 314 330 bytes bzip-after: 614 246 241 bytes +2.15% zstd-before: 604 745 136 bytes zstd-after: 615 497 705 bytes +1.78% none-before: 3 338 238 571 bytes none-after: 3 439 422 535 bytes +3.03% ### mozilla-central bzip-before: 1 493 006 921 bytes bzip-after: 1 549 650 570 bytes +3.79% zstd-before: 1 481 910 102 bytes zstd-after: 1 513 052 415 bytes +2.10% none-before: 6 535 929 910 bytes none-after: 7 010 191 342 bytes +7.26% ### mozilla-try bzip-before: 6 583 425 999 bytes bzip-after: 7 423 536 928 bytes +12.76% zstd-before: 6 021 009 212 bytes zstd-after: 6 674 922 420 bytes +10.86% none-before: 22 954 739 558 bytes none-after: 26 013 854 771 bytes +13.32%
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12478
bb665db49e32 tests: unify test-profile
Matt Mackall <mpm@selenic.com>
parents: 8024
diff changeset
     1
test --time
5099
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     2
16933
30143c3dd102 dispatch: lowercase --time message
Martin Geisler <mg@aragost.com>
parents: 16913
diff changeset
     3
  $ hg --time help -q help 2>&1 | grep time > /dev/null
12478
bb665db49e32 tests: unify test-profile
Matt Mackall <mpm@selenic.com>
parents: 8024
diff changeset
     4
  $ hg init a
bb665db49e32 tests: unify test-profile
Matt Mackall <mpm@selenic.com>
parents: 8024
diff changeset
     5
  $ cd a
8022
4f3fdfaa3874 profiling: Adding profiling.output config variable
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 8021
diff changeset
     6
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
     7
Function to check that statprof ran
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
     8
  $ statprofran () {
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
     9
  >   egrep 'Sample count:|No samples recorded' > /dev/null
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
    10
  > }
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    11
12478
bb665db49e32 tests: unify test-profile
Matt Mackall <mpm@selenic.com>
parents: 8024
diff changeset
    12
test --profile
8022
4f3fdfaa3874 profiling: Adding profiling.output config variable
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 8021
diff changeset
    13
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
    14
  $ hg st --profile 2>&1 | statprofran
32807
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    15
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    16
Abreviated version
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    17
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
    18
  $ hg st --prof 2>&1 | statprofran
32807
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    19
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    20
In alias
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    21
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
    22
  $ hg --config "alias.profst=status --profile" profst 2>&1 | statprofran
32807
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    23
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    24
#if lsprof
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32455
diff changeset
    25
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    26
  $ prof () {
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    27
  >   hg --config profiling.type=ls --profile $@
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    28
  > }
30273
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29798
diff changeset
    29
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    30
  $ prof st 2>../out
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    31
  $ grep CallCount ../out > /dev/null || cat ../out
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    32
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    33
  $ prof --config profiling.output=../out st
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    34
  $ grep CallCount ../out > /dev/null || cat ../out
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    35
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    36
  $ prof --config profiling.output=blackbox --config extensions.blackbox= st
26191
39a0b11158d8 profiling: allow logging profile to the blackbox
Durham Goode <durham@fb.com>
parents: 18765
diff changeset
    37
  $ grep CallCount .hg/blackbox.log > /dev/null || cat .hg/blackbox.log
39a0b11158d8 profiling: allow logging profile to the blackbox
Durham Goode <durham@fb.com>
parents: 18765
diff changeset
    38
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    39
  $ prof --config profiling.format=text st 2>../out
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    40
  $ grep CallCount ../out > /dev/null || cat ../out
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    41
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    42
  $ echo "[profiling]" >> $HGRCPATH
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    43
  $ echo "format=kcachegrind" >> $HGRCPATH
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    44
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    45
  $ prof st 2>../out
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    46
  $ grep 'events: Ticks' ../out > /dev/null || cat ../out
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    47
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    48
  $ prof --config profiling.output=../out st
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    49
  $ grep 'events: Ticks' ../out > /dev/null || cat ../out
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    50
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    51
#endif
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16898
diff changeset
    52
29798
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    53
#if lsprof serve
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    54
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    55
Profiling of HTTP requests works
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    56
47562
17fde6763286 windows: use shell function instead of variable substitution
Raphaël Gomès <rgomes@octobus.net>
parents: 46033
diff changeset
    57
  $ prof --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log
29798
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    58
  $ cat ../hg.pid >> $DAEMON_PIDS
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    59
  $ hg -q clone -U http://localhost:$HGPORT ../clone
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    60
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    61
A single profile is logged because file logging doesn't append
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    62
  $ grep CallCount ../profile.log | wc -l
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    63
  \s*1 (re)
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    64
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    65
#endif
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    66
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    67
Install an extension that can sleep and guarantee a profiler has time to run
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    68
46033
8b0a3ff5ed12 statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents: 46032
diff changeset
    69
  $ cat >> sleepext_with_a_long_filename.py << EOF
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    70
  > import time
40369
ef6cab7930b3 py3: fix module imports in tests, as flagged by test-check-module-imports.t
Matt Harbison <matt_harbison@yahoo.com>
parents: 40200
diff changeset
    71
  > from mercurial import registrar
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    72
  > cmdtable = {}
32376
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32060
diff changeset
    73
  > command = registrar.command(cmdtable)
38108
fd8eedcc3fd2 py3: add b'' prefixes in tests/test-profile.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35400
diff changeset
    74
  > @command(b'sleep', [], b'hg sleep')
46033
8b0a3ff5ed12 statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents: 46032
diff changeset
    75
  > def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs):
47563
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
    76
  >     t = time.time()  # don't use time.sleep because we need CPU time
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
    77
  >     while time.time() - t < 0.5:
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
    78
  >         pass
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    79
  > EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    80
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    81
  $ cat >> $HGRCPATH << EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    82
  > [extensions]
46033
8b0a3ff5ed12 statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents: 46032
diff changeset
    83
  > sleep = `pwd`/sleepext_with_a_long_filename.py
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    84
  > EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    85
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    86
statistical profiler works
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    87
30330
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30329
diff changeset
    88
  $ hg --profile sleep 2>../out
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
    89
  $ cat ../out | statprofran
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    90
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    91
Various statprof formatters work
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    92
40533
4e6ffcb5b9fc tests: add some helpful `|| cat` bits to test-profile.t
Augie Fackler <augie@google.com>
parents: 40381
diff changeset
    93
  $ hg --profile --config profiling.statformat=byline sleep 2>../out || cat ../out
45634
ede4a1bf14bd test: try to unflaky test-profile.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 40682
diff changeset
    94
  $ grep -v _path_stat ../out | head -n 3
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    95
    %   cumulative      self          
40381
4613f9274fc0 statprof: update the name as the i increases (issue6003)
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40380
diff changeset
    96
   time    seconds   seconds  name    
46033
8b0a3ff5ed12 statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents: 46032
diff changeset
    97
  * sleepext_with_a_long_filename.py:*:sleep_for_at_least_one_stat_cycle (glob)
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
    98
  $ cat ../out | statprofran
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
    99
40533
4e6ffcb5b9fc tests: add some helpful `|| cat` bits to test-profile.t
Augie Fackler <augie@google.com>
parents: 40381
diff changeset
   100
  $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
   101
  $ head -n 1 ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
   102
    %   cumulative      self          
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
   103
  $ cat ../out | statprofran
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
   104
47563
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   105
Windows real time tracking is broken, only use CPU
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   106
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   107
#if no-windows
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   108
  $ hg --profile --config profiling.time-track=real --config profiling.statformat=hotpath sleep 2>../out || cat ../out
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33109
diff changeset
   109
  $ cat ../out | statprofran
47563
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   110
  $ grep sleepext_with_a_long_filename.py ../out | head -n 1
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   111
  .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   112
#endif
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   113
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   114
  $ hg --profile --config profiling.time-track=cpu --config profiling.statformat=hotpath sleep 2>../out || cat ../out
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   115
  $ cat ../out | statprofran
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   116
  $ grep sleepext_with_a_long_filename.py ../out | head -n 1
dc3f7aa15423 windows: use cpu-intensive task instead of real time in test
Raphaël Gomès <rgomes@octobus.net>
parents: 47562
diff changeset
   117
  .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
   118
40533
4e6ffcb5b9fc tests: add some helpful `|| cat` bits to test-profile.t
Augie Fackler <augie@google.com>
parents: 40381
diff changeset
   119
  $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
   120
  $ cat ../out
32060
49145a2b2fb0 test-profile: allow negative time in JSON output (issue5542)
Yuya Nishihara <yuya@tcha.org>
parents: 30845
diff changeset
   121
  \[\[-?\d+.* (re)
30329
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30273
diff changeset
   122
30845
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30330
diff changeset
   123
statprof can be used as a standalone module
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30330
diff changeset
   124
39723
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 38108
diff changeset
   125
  $ "$PYTHON" -m mercurial.statprof hotpath
30845
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30330
diff changeset
   126
  must specify --file to load
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30330
diff changeset
   127
  [1]
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30330
diff changeset
   128
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16898
diff changeset
   129
  $ cd ..
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   130
34446
5b19f0442043 test-profile: gate chg-incompatible part with '#if chg'
Jun Wu <quark@fb.com>
parents: 33609
diff changeset
   131
#if no-chg
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   132
profiler extension could be loaded before other extensions
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   133
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   134
  $ cat > fooprof.py <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   135
  > import contextlib
40200
9cc411952ab9 py3: flush stdout
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39723
diff changeset
   136
  > import sys
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   137
  > @contextlib.contextmanager
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   138
  > def profile(ui, fp):
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   139
  >     print('fooprof: start profile')
40200
9cc411952ab9 py3: flush stdout
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39723
diff changeset
   140
  >     sys.stdout.flush()
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   141
  >     yield
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   142
  >     print('fooprof: end profile')
40200
9cc411952ab9 py3: flush stdout
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39723
diff changeset
   143
  >     sys.stdout.flush()
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   144
  > def extsetup(ui):
38108
fd8eedcc3fd2 py3: add b'' prefixes in tests/test-profile.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35400
diff changeset
   145
  >     ui.write(b'fooprof: loaded\n')
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   146
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   147
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   148
  $ cat > otherextension.py <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   149
  > def extsetup(ui):
38108
fd8eedcc3fd2 py3: add b'' prefixes in tests/test-profile.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35400
diff changeset
   150
  >     ui.write(b'otherextension: loaded\n')
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   151
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   152
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   153
  $ hg init b
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   154
  $ cd b
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   155
  $ cat >> .hg/hgrc <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   156
  > [extensions]
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   157
  > other = $TESTTMP/otherextension.py
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   158
  > fooprof = $TESTTMP/fooprof.py
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   159
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   160
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   161
  $ hg root
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   162
  otherextension: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   163
  fooprof: loaded
35400
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 34446
diff changeset
   164
  $TESTTMP/b
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   165
  $ HGPROF=fooprof hg root --profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   166
  fooprof: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   167
  fooprof: start profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   168
  otherextension: loaded
35400
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 34446
diff changeset
   169
  $TESTTMP/b
32455
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   170
  fooprof: end profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   171
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   172
  $ HGPROF=other hg root --profile 2>&1 | head -n 2
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   173
  otherextension: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   174
  unrecognized profiler 'other' - ignored
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   175
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   176
  $ HGPROF=unknown hg root --profile 2>&1 | head -n 1
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   177
  unrecognized profiler 'unknown' - ignored
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   178
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32376
diff changeset
   179
  $ cd ..
34446
5b19f0442043 test-profile: gate chg-incompatible part with '#if chg'
Jun Wu <quark@fb.com>
parents: 33609
diff changeset
   180
#endif