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