|
5 | 5 |
|
6 | 6 | func Test_profile_func()
|
7 | 7 | let lines = [
|
| 8 | + \ 'profile start Xprofile_func.log', |
| 9 | + \ 'profile func Foo*"', |
8 | 10 | \ "func! Foo1()",
|
9 | 11 | \ "endfunc",
|
10 | 12 | \ "func! Foo2()",
|
@@ -33,9 +35,7 @@ func Test_profile_func()
|
33 | 35 |
|
34 | 36 | call writefile(lines, 'Xprofile_func.vim')
|
35 | 37 | call system(v:progpath
|
36 |
| - \ . ' -es -u NONE -U NONE -i NONE --noplugin' |
37 |
| - \ . ' -c "profile start Xprofile_func.log"' |
38 |
| - \ . ' -c "profile func Foo*"' |
| 38 | + \ . ' -es --clean' |
39 | 39 | \ . ' -c "so Xprofile_func.vim"'
|
40 | 40 | \ . ' -c "qall!"')
|
41 | 41 | call assert_equal(0, v:shell_error)
|
@@ -97,7 +97,7 @@ func Test_profile_file()
|
97 | 97 |
|
98 | 98 | call writefile(lines, 'Xprofile_file.vim')
|
99 | 99 | call system(v:progpath
|
100 |
| - \ . ' -es -u NONE -U NONE -i NONE --noplugin' |
| 100 | + \ . ' -es --clean' |
101 | 101 | \ . ' -c "profile start Xprofile_file.log"'
|
102 | 102 | \ . ' -c "profile file Xprofile_file.vim"'
|
103 | 103 | \ . ' -c "so Xprofile_file.vim"'
|
@@ -152,17 +152,17 @@ func Test_profile_file_with_cont()
|
152 | 152 | let lines = readfile('Xprofile_file.log')
|
153 | 153 | call assert_equal(11, len(lines))
|
154 | 154 |
|
155 |
| - call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0]) |
156 |
| - call assert_equal('Sourced 1 time', lines[1]) |
157 |
| - call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2]) |
158 |
| - call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) |
159 |
| - call assert_equal('', lines[4]) |
160 |
| - call assert_equal('count total (s) self (s)', lines[5]) |
161 |
| - call assert_match(' 1 0.\d\+ echo "hello', lines[6]) |
162 |
| - call assert_equal(' \ world"', lines[7]) |
163 |
| - call assert_match(' 1 0.\d\+ echo "foo ', lines[8]) |
164 |
| - call assert_equal(' \bar"', lines[9]) |
165 |
| - call assert_equal('', lines[10]) |
| 155 | + call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0]) |
| 156 | + call assert_equal('Sourced 1 time', lines[1]) |
| 157 | + call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2]) |
| 158 | + call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) |
| 159 | + call assert_equal('', lines[4]) |
| 160 | + call assert_equal('count total (s) self (s)', lines[5]) |
| 161 | + call assert_match(' 1 0.\d\+ echo "hello', lines[6]) |
| 162 | + call assert_equal(' \ world"', lines[7]) |
| 163 | + call assert_match(' 1 0.\d\+ echo "foo ', lines[8]) |
| 164 | + call assert_equal(' \bar"', lines[9]) |
| 165 | + call assert_equal('', lines[10]) |
166 | 166 |
|
167 | 167 | call delete('Xprofile_file.vim')
|
168 | 168 | call delete('Xprofile_file.log')
|
@@ -222,3 +222,73 @@ func Test_profile_truncate_mbyte()
|
222 | 222 | call delete('Xprofile_file.vim')
|
223 | 223 | call delete('Xprofile_file.log')
|
224 | 224 | endfunc
|
| 225 | + |
| 226 | +func Test_profdel_func() |
| 227 | + let lines = [ |
| 228 | + \ 'profile start Xprofile_file.log', |
| 229 | + \ 'func! Foo1()', |
| 230 | + \ 'endfunc', |
| 231 | + \ 'func! Foo2()', |
| 232 | + \ 'endfunc', |
| 233 | + \ 'func! Foo3()', |
| 234 | + \ 'endfunc', |
| 235 | + \ '', |
| 236 | + \ 'profile func Foo1', |
| 237 | + \ 'profile func Foo2', |
| 238 | + \ 'call Foo1()', |
| 239 | + \ 'call Foo2()', |
| 240 | + \ '', |
| 241 | + \ 'profile func Foo3', |
| 242 | + \ 'profdel func Foo2', |
| 243 | + \ 'profdel func Foo3', |
| 244 | + \ 'call Foo1()', |
| 245 | + \ 'call Foo2()', |
| 246 | + \ 'call Foo3()' ] |
| 247 | + call writefile(lines, 'Xprofile_file.vim') |
| 248 | + call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q') |
| 249 | + call assert_equal(0, v:shell_error) |
| 250 | + |
| 251 | + let lines = readfile('Xprofile_file.log') |
| 252 | + call assert_equal(24, len(lines)) |
| 253 | + |
| 254 | + " Check that: |
| 255 | + " - Foo1() is called twice (profdel not invoked) |
| 256 | + " - Foo2() is called once (profdel invoked after it was called) |
| 257 | + " - Foo3() is not called (profdel invoked before it was called) |
| 258 | + call assert_equal('FUNCTION Foo1()', lines[0]) |
| 259 | + call assert_equal('Called 2 times', lines[1]) |
| 260 | + call assert_equal('FUNCTION Foo2()', lines[7]) |
| 261 | + call assert_equal('Called 1 time', lines[8]) |
| 262 | + call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[14]) |
| 263 | + call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[19]) |
| 264 | + |
| 265 | + call delete('Xprofile_file.vim') |
| 266 | + call delete('Xprofile_file.log') |
| 267 | +endfunc |
| 268 | + |
| 269 | +func Test_profdel_star() |
| 270 | + " Foo() is invoked once before and once after 'profdel *'. |
| 271 | + " So profiling should report it only once. |
| 272 | + let lines = [ |
| 273 | + \ 'profile start Xprofile_file.log', |
| 274 | + \ 'func! Foo()', |
| 275 | + \ 'endfunc', |
| 276 | + \ 'profile func Foo', |
| 277 | + \ 'call Foo()', |
| 278 | + \ 'profdel *', |
| 279 | + \ 'call Foo()' ] |
| 280 | + call writefile(lines, 'Xprofile_file.vim') |
| 281 | + call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q') |
| 282 | + call assert_equal(0, v:shell_error) |
| 283 | + |
| 284 | + let lines = readfile('Xprofile_file.log') |
| 285 | + call assert_equal(15, len(lines)) |
| 286 | + |
| 287 | + call assert_equal('FUNCTION Foo()', lines[0]) |
| 288 | + call assert_equal('Called 1 time', lines[1]) |
| 289 | + call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[7]) |
| 290 | + call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[11]) |
| 291 | + |
| 292 | + call delete('Xprofile_file.vim') |
| 293 | + call delete('Xprofile_file.log') |
| 294 | +endfunc |
0 commit comments