tests/test-profile.t
author Pulkit Goyal <7895pulkit@gmail.com>
Sat, 17 Jun 2017 15:29:26 +0530
changeset 32897 799db2af824c
parent 32787 545f69cd6042
child 33097 fce4ed2912bb
permissions -rw-r--r--
py3: convert keys of kwargs back to bytes using pycompat.byteskwargs()
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
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
     7
12478
bb665db49e32 tests: unify test-profile
Matt Mackall <mpm@selenic.com>
parents: 8024
diff changeset
     8
test --profile
8022
4f3fdfaa3874 profiling: Adding profiling.output config variable
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 8021
diff changeset
     9
32787
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    10
  $ hg st --profile 2>&1 | grep Sample
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    11
  Sample count: \d+ (re)
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    12
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    13
Abreviated version
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    14
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    15
  $ hg st --prof 2>&1 | grep Sample
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    16
  Sample count: \d+ (re)
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    17
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    18
In alias
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
  $ hg --config "alias.profst=status --profile" profst 2>&1 | grep Sample
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    21
  Sample count: \d+ (re)
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    22
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    23
#if lsprof
545f69cd6042 profile: support --profile in alias and abbreviated version (--prof)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32417
diff changeset
    24
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    25
  $ prof='hg --config profiling.type=ls --profile'
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    26
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    27
  $ $prof st 2>../out
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    28
  $ 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
    29
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    30
  $ $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
    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
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    33
  $ $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
    34
  $ 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
    35
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    36
  $ $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
    37
  $ 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
    38
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    39
  $ echo "[profiling]" >> $HGRCPATH
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    40
  $ echo "format=kcachegrind" >> $HGRCPATH
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    41
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    42
  $ $prof st 2>../out
16898
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    43
  $ 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
    44
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    45
  $ $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
    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
bb91c602d4ad tests: change odd uses of 'if hghave' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 12478
diff changeset
    48
#endif
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16898
diff changeset
    49
29787
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    50
#if lsprof serve
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    51
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    52
Profiling of HTTP requests works
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    53
30259
d06c049695e6 tests: explicitly use ls profiler
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29787
diff changeset
    54
  $ $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
    55
  $ cat ../hg.pid >> $DAEMON_PIDS
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    56
  $ hg -q clone -U http://localhost:$HGPORT ../clone
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    57
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    58
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
    59
  $ grep CallCount ../profile.log | wc -l
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    60
  \s*1 (re)
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    61
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    62
#endif
80df04266a16 hgweb: profile HTTP requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26191
diff changeset
    63
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    64
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
    65
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    66
  $ cat >> sleepext.py << EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    67
  > import time
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32060
diff changeset
    68
  > 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
    69
  > cmdtable = {}
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32060
diff changeset
    70
  > command = registrar.command(cmdtable)
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    71
  > @command('sleep', [], 'hg sleep')
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    72
  > def sleep(ui, *args, **kwargs):
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    73
  >     time.sleep(0.1)
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    74
  > EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    75
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    76
  $ cat >> $HGRCPATH << EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    77
  > [extensions]
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    78
  > sleep = `pwd`/sleepext.py
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    79
  > EOF
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    80
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    81
statistical profiler works
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    82
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
    83
  $ hg --profile sleep 2>../out
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    84
  $ grep Sample ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    85
  Sample count: \d+ (re)
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          
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    92
  $ grep Sample ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    93
  Sample count: \d+ (re)
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    94
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
    95
  $ 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
    96
  $ head -n 1 ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    97
    %   cumulative      self          
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    98
  $ grep Sample ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
    99
  Sample count: \d+ (re)
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   100
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
   101
  $ hg --profile --config profiling.statformat=hotpath sleep 2>../out
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   102
  $ grep Sample ../out
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   103
  Sample count: \d+ (re)
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   104
30317
3fd53cc1aad8 profiling: make statprof the default profiler (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30316
diff changeset
   105
  $ 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
   106
  $ cat ../out
32060
49145a2b2fb0 test-profile: allow negative time in JSON output (issue5542)
Yuya Nishihara <yuya@tcha.org>
parents: 30845
diff changeset
   107
  \[\[-?\d+.* (re)
30316
faf1b8923da2 profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30259
diff changeset
   108
30845
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   109
statprof can be used as a standalone module
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   110
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   111
  $ $PYTHON -m mercurial.statprof hotpath
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   112
  must specify --file to load
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   113
  [1]
262c2be8ea5a statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30317
diff changeset
   114
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16898
diff changeset
   115
  $ cd ..
32417
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
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
   118
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   119
  $ cat > fooprof.py <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   120
  > from __future__ import absolute_import
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   121
  > import contextlib
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   122
  > @contextlib.contextmanager
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   123
  > def profile(ui, fp):
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   124
  >     print('fooprof: start profile')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   125
  >     yield
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   126
  >     print('fooprof: end profile')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   127
  > def extsetup(ui):
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   128
  >     ui.write('fooprof: loaded\n')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   129
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   130
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   131
  $ cat > otherextension.py <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   132
  > from __future__ import absolute_import
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   133
  > def extsetup(ui):
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   134
  >     ui.write('otherextension: loaded\n')
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   135
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   136
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   137
  $ hg init b
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   138
  $ cd b
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   139
  $ cat >> .hg/hgrc <<EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   140
  > [extensions]
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   141
  > other = $TESTTMP/otherextension.py
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   142
  > fooprof = $TESTTMP/fooprof.py
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   143
  > EOF
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   144
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   145
  $ hg root
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   146
  otherextension: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   147
  fooprof: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   148
  $TESTTMP/b (glob)
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   149
  $ HGPROF=fooprof hg root --profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   150
  fooprof: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   151
  fooprof: start profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   152
  otherextension: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   153
  $TESTTMP/b (glob)
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   154
  fooprof: end profile
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   155
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   156
  $ 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
   157
  otherextension: loaded
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   158
  unrecognized profiler 'other' - ignored
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   159
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   160
  $ 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
   161
  unrecognized profiler 'unknown' - ignored
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   162
f40dc6f7c12f profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents: 32337
diff changeset
   163
  $ cd ..