Show More
@@ -1,169 +1,171 b'' | |||||
1 | test --time |
|
1 | test --time | |
2 |
|
2 | |||
3 | $ hg --time help -q help 2>&1 | grep time > /dev/null |
|
3 | $ hg --time help -q help 2>&1 | grep time > /dev/null | |
4 | $ hg init a |
|
4 | $ hg init a | |
5 | $ cd a |
|
5 | $ cd a | |
6 |
|
6 | |||
7 | Function to check that statprof ran |
|
7 | Function to check that statprof ran | |
8 | $ statprofran () { |
|
8 | $ statprofran () { | |
9 | > egrep 'Sample count:|No samples recorded' > /dev/null |
|
9 | > egrep 'Sample count:|No samples recorded' > /dev/null | |
10 | > } |
|
10 | > } | |
11 |
|
11 | |||
12 | test --profile |
|
12 | test --profile | |
13 |
|
13 | |||
14 | $ hg st --profile 2>&1 | statprofran |
|
14 | $ hg st --profile 2>&1 | statprofran | |
15 |
|
15 | |||
16 | Abreviated version |
|
16 | Abreviated version | |
17 |
|
17 | |||
18 | $ hg st --prof 2>&1 | statprofran |
|
18 | $ hg st --prof 2>&1 | statprofran | |
19 |
|
19 | |||
20 | In alias |
|
20 | In alias | |
21 |
|
21 | |||
22 | $ hg --config "alias.profst=status --profile" profst 2>&1 | statprofran |
|
22 | $ hg --config "alias.profst=status --profile" profst 2>&1 | statprofran | |
23 |
|
23 | |||
24 | #if lsprof |
|
24 | #if lsprof | |
25 |
|
25 | |||
26 | $ prof='hg --config profiling.type=ls --profile' |
|
26 | $ prof () { | |
|
27 | > hg --config profiling.type=ls --profile $@ | |||
|
28 | > } | |||
27 |
|
29 | |||
28 |
$ |
|
30 | $ prof st 2>../out | |
29 |
$ |
|
31 | $ grep CallCount ../out > /dev/null || cat ../out | |
30 |
|
32 | |||
31 |
$ |
|
33 | $ prof --config profiling.output=../out st | |
32 | $ grep CallCount ../out > /dev/null || cat ../out |
|
34 | $ grep CallCount ../out > /dev/null || cat ../out | |
33 |
|
35 | |||
34 |
$ |
|
36 | $ prof --config profiling.output=blackbox --config extensions.blackbox= st | |
35 | $ grep CallCount .hg/blackbox.log > /dev/null || cat .hg/blackbox.log |
|
37 | $ grep CallCount .hg/blackbox.log > /dev/null || cat .hg/blackbox.log | |
36 |
|
38 | |||
37 |
$ |
|
39 | $ prof --config profiling.format=text st 2>../out | |
38 | $ grep CallCount ../out > /dev/null || cat ../out |
|
40 | $ grep CallCount ../out > /dev/null || cat ../out | |
39 |
|
41 | |||
40 | $ echo "[profiling]" >> $HGRCPATH |
|
42 | $ echo "[profiling]" >> $HGRCPATH | |
41 | $ echo "format=kcachegrind" >> $HGRCPATH |
|
43 | $ echo "format=kcachegrind" >> $HGRCPATH | |
42 |
|
44 | |||
43 |
$ |
|
45 | $ prof st 2>../out | |
44 | $ grep 'events: Ticks' ../out > /dev/null || cat ../out |
|
46 | $ grep 'events: Ticks' ../out > /dev/null || cat ../out | |
45 |
|
47 | |||
46 |
$ |
|
48 | $ prof --config profiling.output=../out st | |
47 | $ grep 'events: Ticks' ../out > /dev/null || cat ../out |
|
49 | $ grep 'events: Ticks' ../out > /dev/null || cat ../out | |
48 |
|
50 | |||
49 | #endif |
|
51 | #endif | |
50 |
|
52 | |||
51 | #if lsprof serve |
|
53 | #if lsprof serve | |
52 |
|
54 | |||
53 | Profiling of HTTP requests works |
|
55 | Profiling of HTTP requests works | |
54 |
|
56 | |||
55 |
$ |
|
57 | $ prof --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log | |
56 | $ cat ../hg.pid >> $DAEMON_PIDS |
|
58 | $ cat ../hg.pid >> $DAEMON_PIDS | |
57 | $ hg -q clone -U http://localhost:$HGPORT ../clone |
|
59 | $ hg -q clone -U http://localhost:$HGPORT ../clone | |
58 |
|
60 | |||
59 | A single profile is logged because file logging doesn't append |
|
61 | A single profile is logged because file logging doesn't append | |
60 | $ grep CallCount ../profile.log | wc -l |
|
62 | $ grep CallCount ../profile.log | wc -l | |
61 | \s*1 (re) |
|
63 | \s*1 (re) | |
62 |
|
64 | |||
63 | #endif |
|
65 | #endif | |
64 |
|
66 | |||
65 | Install an extension that can sleep and guarantee a profiler has time to run |
|
67 | Install an extension that can sleep and guarantee a profiler has time to run | |
66 |
|
68 | |||
67 | $ cat >> sleepext_with_a_long_filename.py << EOF |
|
69 | $ cat >> sleepext_with_a_long_filename.py << EOF | |
68 | > import time |
|
70 | > import time | |
69 | > from mercurial import registrar |
|
71 | > from mercurial import registrar | |
70 | > cmdtable = {} |
|
72 | > cmdtable = {} | |
71 | > command = registrar.command(cmdtable) |
|
73 | > command = registrar.command(cmdtable) | |
72 | > @command(b'sleep', [], b'hg sleep') |
|
74 | > @command(b'sleep', [], b'hg sleep') | |
73 | > def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs): |
|
75 | > def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs): | |
74 | > time.sleep(0.1) |
|
76 | > time.sleep(0.1) | |
75 | > EOF |
|
77 | > EOF | |
76 |
|
78 | |||
77 | $ cat >> $HGRCPATH << EOF |
|
79 | $ cat >> $HGRCPATH << EOF | |
78 | > [extensions] |
|
80 | > [extensions] | |
79 | > sleep = `pwd`/sleepext_with_a_long_filename.py |
|
81 | > sleep = `pwd`/sleepext_with_a_long_filename.py | |
80 | > EOF |
|
82 | > EOF | |
81 |
|
83 | |||
82 | statistical profiler works |
|
84 | statistical profiler works | |
83 |
|
85 | |||
84 | $ hg --profile sleep 2>../out |
|
86 | $ hg --profile sleep 2>../out | |
85 | $ cat ../out | statprofran |
|
87 | $ cat ../out | statprofran | |
86 |
|
88 | |||
87 | Various statprof formatters work |
|
89 | Various statprof formatters work | |
88 |
|
90 | |||
89 | $ hg --profile --config profiling.statformat=byline sleep 2>../out || cat ../out |
|
91 | $ hg --profile --config profiling.statformat=byline sleep 2>../out || cat ../out | |
90 | $ grep -v _path_stat ../out | head -n 3 |
|
92 | $ grep -v _path_stat ../out | head -n 3 | |
91 | % cumulative self |
|
93 | % cumulative self | |
92 | time seconds seconds name |
|
94 | time seconds seconds name | |
93 | * sleepext_with_a_long_filename.py:*:sleep_for_at_least_one_stat_cycle (glob) |
|
95 | * sleepext_with_a_long_filename.py:*:sleep_for_at_least_one_stat_cycle (glob) | |
94 | $ cat ../out | statprofran |
|
96 | $ cat ../out | statprofran | |
95 |
|
97 | |||
96 | $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out |
|
98 | $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out | |
97 | $ head -n 1 ../out |
|
99 | $ head -n 1 ../out | |
98 | % cumulative self |
|
100 | % cumulative self | |
99 | $ cat ../out | statprofran |
|
101 | $ cat ../out | statprofran | |
100 |
|
102 | |||
101 | $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out |
|
103 | $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out | |
102 | $ cat ../out | statprofran |
|
104 | $ cat ../out | statprofran | |
103 | $ grep sleepext_with_a_long_filename.py ../out |
|
105 | $ grep sleepext_with_a_long_filename.py ../out | |
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) |
|
106 | .* [0-9.]+% [0-9.]+s sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line 7: time\.sleep.* (re) | |
105 |
|
107 | |||
106 | $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out |
|
108 | $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out | |
107 | $ cat ../out |
|
109 | $ cat ../out | |
108 | \[\[-?\d+.* (re) |
|
110 | \[\[-?\d+.* (re) | |
109 |
|
111 | |||
110 | statprof can be used as a standalone module |
|
112 | statprof can be used as a standalone module | |
111 |
|
113 | |||
112 | $ "$PYTHON" -m mercurial.statprof hotpath |
|
114 | $ "$PYTHON" -m mercurial.statprof hotpath | |
113 | must specify --file to load |
|
115 | must specify --file to load | |
114 | [1] |
|
116 | [1] | |
115 |
|
117 | |||
116 | $ cd .. |
|
118 | $ cd .. | |
117 |
|
119 | |||
118 | #if no-chg |
|
120 | #if no-chg | |
119 | profiler extension could be loaded before other extensions |
|
121 | profiler extension could be loaded before other extensions | |
120 |
|
122 | |||
121 | $ cat > fooprof.py <<EOF |
|
123 | $ cat > fooprof.py <<EOF | |
122 | > from __future__ import absolute_import |
|
124 | > from __future__ import absolute_import | |
123 | > import contextlib |
|
125 | > import contextlib | |
124 | > import sys |
|
126 | > import sys | |
125 | > @contextlib.contextmanager |
|
127 | > @contextlib.contextmanager | |
126 | > def profile(ui, fp): |
|
128 | > def profile(ui, fp): | |
127 | > print('fooprof: start profile') |
|
129 | > print('fooprof: start profile') | |
128 | > sys.stdout.flush() |
|
130 | > sys.stdout.flush() | |
129 | > yield |
|
131 | > yield | |
130 | > print('fooprof: end profile') |
|
132 | > print('fooprof: end profile') | |
131 | > sys.stdout.flush() |
|
133 | > sys.stdout.flush() | |
132 | > def extsetup(ui): |
|
134 | > def extsetup(ui): | |
133 | > ui.write(b'fooprof: loaded\n') |
|
135 | > ui.write(b'fooprof: loaded\n') | |
134 | > EOF |
|
136 | > EOF | |
135 |
|
137 | |||
136 | $ cat > otherextension.py <<EOF |
|
138 | $ cat > otherextension.py <<EOF | |
137 | > from __future__ import absolute_import |
|
139 | > from __future__ import absolute_import | |
138 | > def extsetup(ui): |
|
140 | > def extsetup(ui): | |
139 | > ui.write(b'otherextension: loaded\n') |
|
141 | > ui.write(b'otherextension: loaded\n') | |
140 | > EOF |
|
142 | > EOF | |
141 |
|
143 | |||
142 | $ hg init b |
|
144 | $ hg init b | |
143 | $ cd b |
|
145 | $ cd b | |
144 | $ cat >> .hg/hgrc <<EOF |
|
146 | $ cat >> .hg/hgrc <<EOF | |
145 | > [extensions] |
|
147 | > [extensions] | |
146 | > other = $TESTTMP/otherextension.py |
|
148 | > other = $TESTTMP/otherextension.py | |
147 | > fooprof = $TESTTMP/fooprof.py |
|
149 | > fooprof = $TESTTMP/fooprof.py | |
148 | > EOF |
|
150 | > EOF | |
149 |
|
151 | |||
150 | $ hg root |
|
152 | $ hg root | |
151 | otherextension: loaded |
|
153 | otherextension: loaded | |
152 | fooprof: loaded |
|
154 | fooprof: loaded | |
153 | $TESTTMP/b |
|
155 | $TESTTMP/b | |
154 | $ HGPROF=fooprof hg root --profile |
|
156 | $ HGPROF=fooprof hg root --profile | |
155 | fooprof: loaded |
|
157 | fooprof: loaded | |
156 | fooprof: start profile |
|
158 | fooprof: start profile | |
157 | otherextension: loaded |
|
159 | otherextension: loaded | |
158 | $TESTTMP/b |
|
160 | $TESTTMP/b | |
159 | fooprof: end profile |
|
161 | fooprof: end profile | |
160 |
|
162 | |||
161 | $ HGPROF=other hg root --profile 2>&1 | head -n 2 |
|
163 | $ HGPROF=other hg root --profile 2>&1 | head -n 2 | |
162 | otherextension: loaded |
|
164 | otherextension: loaded | |
163 | unrecognized profiler 'other' - ignored |
|
165 | unrecognized profiler 'other' - ignored | |
164 |
|
166 | |||
165 | $ HGPROF=unknown hg root --profile 2>&1 | head -n 1 |
|
167 | $ HGPROF=unknown hg root --profile 2>&1 | head -n 1 | |
166 | unrecognized profiler 'unknown' - ignored |
|
168 | unrecognized profiler 'unknown' - ignored | |
167 |
|
169 | |||
168 | $ cd .. |
|
170 | $ cd .. | |
169 | #endif |
|
171 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now