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