tests/test-profile.t
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 20 Jan 2018 22:55:42 -0800
changeset 35793 4fb2bb61597c
parent 35393 4441705b7111
child 38075 fd8eedcc3fd2
permissions -rw-r--r--
bundle2: increase payload part chunk size to 32kb Bundle2 payload parts are framed chunks. Esentially, we obtain data in equal size chunks of size `preferedchunksize` and emit those to a generator. That generator is fed into a compressor (which can be the no-op compressor, which just re-emits the generator). And the output from the compressor likely goes to a file descriptor or socket. What this means is that small chunk sizes create more Python objects and Python function calls than larger chunk sizes. And as we know, Python object and function call overhead in performance sensitive code matters (at least with CPython). This commit increases the bundle2 part payload chunk size from 4k to 32k. Practically speaking, this means that the chunks we feed into a compressor (implemented in C code) or feed directly into a file handle or socket write() are larger. It's possible the chunks might be larger than what the receiver can handle in one logical operation. But at that point, we're in C code, which is much more efficient at dealing with splitting up the chunk and making multiple function calls than Python is. A downside to larger chunks is that the receiver has to wait for that much data to arrive (either raw or from a decompressor) before it can process the chunk. But 32kb still feels like a small buffer to have to wait for. And in many cases, the client will convert from 8 read(4096) to 1 read(32768). That's happening in Python land. So we cut down on the number of Python objects and function calls, making the client faster as well. I don't think there are any significant concerns to increasing the payload chunk size to 32kb. The impact of this change on performance significant. Using `curl` to obtain a stream clone bundle2 payload from a server on localhost serving the mozilla-unified repository: before: 20.78 user; 7.71 system; 80.5 MB/s after: 13.90 user; 3.51 system; 132 MB/s legacy: 9.72 user; 8.16 system; 132 MB/s bundle2 stream clone generation is still more resource intensive than legacy stream clone (that's likely because of the use of a util.chunkbuffer). But the throughput is the same. We might be in territory we're this is effectively a benchmark of the networking stack or Python's syscall throughput. From the client perspective, `hg clone -U --stream`: before: 33.50 user; 7.95 system; 53.3 MB/s after: 22.82 user; 7.33 system; 72.7 MB/s legacy: 29.96 user; 7.94 system; 58.0 MB/s And for `hg clone --stream` with a working directory update of ~230k files: after: 119.55 user; 26.47 system; 0:57.08 wall legacy: 126.98 user; 26.94 system; 1:05.56 wall So, it appears that bundle2's stream clone is now definitively faster than legacy stream clone! Differential Revision: https://phab.mercurial-scm.org/D1932
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: 33097
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: 33097
diff changeset
     8
  $ statprofran () {
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33097
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: 33097
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: 33097
diff changeset
    14
  $ hg st --profile 2>&1 | statprofran
32787
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    15
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    16
Abreviated version
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    17
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33097
diff changeset
    18
  $ hg st --prof 2>&1 | statprofran
32787
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    19
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    20
In alias
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    21
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33097
diff changeset
    22
  $ hg --config "alias.profst=status --profile" profst 2>&1 | statprofran
32787
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    23
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    24
#if lsprof
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    25
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    26
  $ prof='hg --config profiling.type=ls --profile'
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    27
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    28
  $ $prof st 2>../out
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    29
  $ 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
    30
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    31
  $ $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
    32
  $ 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
    33
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    34
  $ $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
    35
  $ 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
    36
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    37
  $ $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
    38
  $ 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
    39
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    40
  $ echo "[profiling]" >> $HGRCPATH
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    41
  $ echo "format=kcachegrind" >> $HGRCPATH
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    42
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    43
  $ $prof st 2>../out
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    44
  $ 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
    45
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    46
  $ $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
    47
  $ 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
    48
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    49
#endif
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16898
diff changeset
    50
29787
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    51
#if lsprof serve
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    52
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    53
Profiling of HTTP requests works
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    54
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    55
  $ $prof --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log
29787
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    56
  $ cat ../hg.pid >> $DAEMON_PIDS
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    57
  $ hg -q clone -U http://localhost:$HGPORT ../clone
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    58
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    59
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
    60
  $ grep CallCount ../profile.log | wc -l
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    61
  \s*1 (re)
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    62
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    63
#endif
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    64
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    65
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: 30259
diff changeset
    66
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    67
  $ cat >> sleepext.py << EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    68
  > import time
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32060
diff changeset
    69
  > from mercurial import registrar, commands
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    70
  > cmdtable = {}
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32060
diff changeset
    71
  > command = registrar.command(cmdtable)
33097
fce4ed2912bb py3: make sure commands name are bytes in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32787
diff changeset
    72
  > @command(b'sleep', [], 'hg sleep')
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    73
  > def sleep(ui, *args, **kwargs):
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    74
  >     time.sleep(0.1)
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    75
  > EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    76
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    77
  $ cat >> $HGRCPATH << EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    78
  > [extensions]
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    79
  > sleep = `pwd`/sleepext.py
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    80
  > EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    81
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    82
statistical profiler works
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    83
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
    84
  $ 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: 33097
diff changeset
    85
  $ cat ../out | statprofran
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    86
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    87
Various statprof formatters work
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    88
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
    89
  $ hg --profile --config profiling.statformat=byline sleep 2>../out
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    90
  $ head -n 1 ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    91
    %   cumulative      self          
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33097
diff changeset
    92
  $ cat ../out | statprofran
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    93
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
    94
  $ hg --profile --config profiling.statformat=bymethod sleep 2>../out
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    95
  $ head -n 1 ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    96
    %   cumulative      self          
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33097
diff changeset
    97
  $ cat ../out | statprofran
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    98
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
    99
  $ hg --profile --config profiling.statformat=hotpath sleep 2>../out
33609
a72b2db1a6a9 tests: make test-profile.t pass if statprof didn't collect samples
Martin von Zweigbergk <martinvonz@google.com>
parents: 33097
diff changeset
   100
  $ cat ../out | statprofran
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   101
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
   102
  $ hg --profile --config profiling.statformat=json sleep 2>../out
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   103
  $ cat ../out
32060
49145a2b2fb0 test-profile: allow negative time in JSON output (issue5542)
Yuya Nishihara <yuya@tcha.org>
parents: 30845
diff changeset
   104
  \[\[-?\d+.* (re)
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   105
30845
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   106
statprof can be used as a standalone module
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   107
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   108
  $ $PYTHON -m mercurial.statprof hotpath
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   109
  must specify --file to load
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   110
  [1]
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   111
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16898
diff changeset
   112
  $ cd ..
32417
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   113
34445
5b19f0442043 test-profile: gate chg-incompatible part with '#if chg'
Jun Wu <quark@fb.com>
parents: 33609
diff changeset
   114
#if no-chg
32417
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   115
profiler extension could be loaded before other extensions
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   116
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   117
  $ cat > fooprof.py <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   118
  > from __future__ import absolute_import
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   119
  > import contextlib
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   120
  > @contextlib.contextmanager
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   121
  > def profile(ui, fp):
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   122
  >     print('fooprof: start profile')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   123
  >     yield
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   124
  >     print('fooprof: end profile')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   125
  > def extsetup(ui):
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   126
  >     ui.write('fooprof: loaded\n')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   127
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   128
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   129
  $ cat > otherextension.py <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   130
  > from __future__ import absolute_import
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   131
  > def extsetup(ui):
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   132
  >     ui.write('otherextension: loaded\n')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   133
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   134
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   135
  $ hg init b
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   136
  $ cd b
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   137
  $ cat >> .hg/hgrc <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   138
  > [extensions]
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   139
  > other = $TESTTMP/otherextension.py
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   140
  > fooprof = $TESTTMP/fooprof.py
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   141
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   142
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   143
  $ hg root
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   144
  otherextension: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   145
  fooprof: loaded
35393
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 34445
diff changeset
   146
  $TESTTMP/b
32417
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   147
  $ HGPROF=fooprof hg root --profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   148
  fooprof: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   149
  fooprof: start profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   150
  otherextension: loaded
35393
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 34445
diff changeset
   151
  $TESTTMP/b
32417
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   152
  fooprof: end profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   153
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   154
  $ 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: 32337
diff changeset
   155
  otherextension: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   156
  unrecognized profiler 'other' - ignored
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   157
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   158
  $ 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: 32337
diff changeset
   159
  unrecognized profiler 'unknown' - ignored
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   160
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   161
  $ cd ..
34445
5b19f0442043 test-profile: gate chg-incompatible part with '#if chg'
Jun Wu <quark@fb.com>
parents: 33609
diff changeset
   162
#endif