author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Mon, 22 Feb 2021 12:21:00 +0100 | |
changeset 46561 | 388a92023a1a |
parent 46018 | 8b0a3ff5ed12 |
child 47562 | 17fde6763286 |
permissions | -rw-r--r-- |
12478 | 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 | 4 |
$ hg init a |
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 | 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 |
|
46018
8b0a3ff5ed12
statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents:
46017
diff
changeset
|
67 |
$ cat >> sleepext_with_a_long_filename.py << EOF |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
68 |
> 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
|
69 |
> from mercurial import registrar |
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) |
38075
fd8eedcc3fd2
py3: add b'' prefixes in tests/test-profile.t
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35393
diff
changeset
|
72 |
> @command(b'sleep', [], b'hg sleep') |
46018
8b0a3ff5ed12
statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents:
46017
diff
changeset
|
73 |
> def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs): |
30316
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] |
46018
8b0a3ff5ed12
statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents:
46017
diff
changeset
|
79 |
> sleep = `pwd`/sleepext_with_a_long_filename.py |
30316
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 |
|
40483
4e6ffcb5b9fc
tests: add some helpful `|| cat` bits to test-profile.t
Augie Fackler <augie@google.com>
parents:
40381
diff
changeset
|
89 |
$ hg --profile --config profiling.statformat=byline sleep 2>../out || cat ../out |
45631
ede4a1bf14bd
test: try to unflaky test-profile.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40639
diff
changeset
|
90 |
$ grep -v _path_stat ../out | head -n 3 |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
91 |
% cumulative self |
40381
4613f9274fc0
statprof: update the name as the i increases (issue6003)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40380
diff
changeset
|
92 |
time seconds seconds name |
46018
8b0a3ff5ed12
statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents:
46017
diff
changeset
|
93 |
* 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:
33097
diff
changeset
|
94 |
$ cat ../out | statprofran |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
95 |
|
40483
4e6ffcb5b9fc
tests: add some helpful `|| cat` bits to test-profile.t
Augie Fackler <augie@google.com>
parents:
40381
diff
changeset
|
96 |
$ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
97 |
$ head -n 1 ../out |
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
98 |
% 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
|
99 |
$ cat ../out | statprofran |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
100 |
|
40483
4e6ffcb5b9fc
tests: add some helpful `|| cat` bits to test-profile.t
Augie Fackler <augie@google.com>
parents:
40381
diff
changeset
|
101 |
$ hg --profile --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:
33097
diff
changeset
|
102 |
$ cat ../out | statprofran |
46018
8b0a3ff5ed12
statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents:
46017
diff
changeset
|
103 |
$ grep sleepext_with_a_long_filename.py ../out |
8b0a3ff5ed12
statprof: separate functions and "line", assume 4 digit line numbers
Kyle Lippincott <spectral@google.com>
parents:
46017
diff
changeset
|
104 |
.* [0-9.]+% [0-9.]+s sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line 7: time\.sleep.* (re) |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
105 |
|
40483
4e6ffcb5b9fc
tests: add some helpful `|| cat` bits to test-profile.t
Augie Fackler <augie@google.com>
parents:
40381
diff
changeset
|
106 |
$ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
107 |
$ cat ../out |
32060
49145a2b2fb0
test-profile: allow negative time in JSON output (issue5542)
Yuya Nishihara <yuya@tcha.org>
parents:
30845
diff
changeset
|
108 |
\[\[-?\d+.* (re) |
30316
faf1b8923da2
profiling: use vendored statprof and upstream enhancements (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30259
diff
changeset
|
109 |
|
30845
262c2be8ea5a
statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30317
diff
changeset
|
110 |
statprof can be used as a standalone module |
262c2be8ea5a
statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30317
diff
changeset
|
111 |
|
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38075
diff
changeset
|
112 |
$ "$PYTHON" -m mercurial.statprof hotpath |
30845
262c2be8ea5a
statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30317
diff
changeset
|
113 |
must specify --file to load |
262c2be8ea5a
statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30317
diff
changeset
|
114 |
[1] |
262c2be8ea5a
statprof: require input file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30317
diff
changeset
|
115 |
|
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16898
diff
changeset
|
116 |
$ cd .. |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
117 |
|
34445
5b19f0442043
test-profile: gate chg-incompatible part with '#if chg'
Jun Wu <quark@fb.com>
parents:
33609
diff
changeset
|
118 |
#if no-chg |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
119 |
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
|
120 |
|
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
121 |
$ cat > fooprof.py <<EOF |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
122 |
> from __future__ import absolute_import |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
123 |
> import contextlib |
40200
9cc411952ab9
py3: flush stdout
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39707
diff
changeset
|
124 |
> import sys |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
125 |
> @contextlib.contextmanager |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
126 |
> def profile(ui, fp): |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
127 |
> print('fooprof: start profile') |
40200
9cc411952ab9
py3: flush stdout
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39707
diff
changeset
|
128 |
> sys.stdout.flush() |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
129 |
> yield |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
130 |
> print('fooprof: end profile') |
40200
9cc411952ab9
py3: flush stdout
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39707
diff
changeset
|
131 |
> sys.stdout.flush() |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
132 |
> def extsetup(ui): |
38075
fd8eedcc3fd2
py3: add b'' prefixes in tests/test-profile.t
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35393
diff
changeset
|
133 |
> ui.write(b'fooprof: loaded\n') |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
134 |
> EOF |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
135 |
|
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
136 |
$ cat > otherextension.py <<EOF |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
137 |
> from __future__ import absolute_import |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
138 |
> def extsetup(ui): |
38075
fd8eedcc3fd2
py3: add b'' prefixes in tests/test-profile.t
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35393
diff
changeset
|
139 |
> ui.write(b'otherextension: loaded\n') |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
140 |
> EOF |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
141 |
|
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
142 |
$ hg init b |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
143 |
$ cd b |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
144 |
$ cat >> .hg/hgrc <<EOF |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
145 |
> [extensions] |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
146 |
> other = $TESTTMP/otherextension.py |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
147 |
> fooprof = $TESTTMP/fooprof.py |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
148 |
> EOF |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
149 |
|
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
150 |
$ hg root |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
151 |
otherextension: loaded |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
152 |
fooprof: loaded |
35393
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
34445
diff
changeset
|
153 |
$TESTTMP/b |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
154 |
$ HGPROF=fooprof hg root --profile |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
155 |
fooprof: loaded |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
156 |
fooprof: start profile |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
157 |
otherextension: loaded |
35393
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
34445
diff
changeset
|
158 |
$TESTTMP/b |
32417
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
159 |
fooprof: end profile |
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 |
$ 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
|
162 |
otherextension: loaded |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
163 |
unrecognized profiler 'other' - ignored |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
164 |
|
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
165 |
$ 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
|
166 |
unrecognized profiler 'unknown' - ignored |
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
167 |
|
f40dc6f7c12f
profiling: allow loading profiling extension before everything else
Jun Wu <quark@fb.com>
parents:
32337
diff
changeset
|
168 |
$ cd .. |
34445
5b19f0442043
test-profile: gate chg-incompatible part with '#if chg'
Jun Wu <quark@fb.com>
parents:
33609
diff
changeset
|
169 |
#endif |