blob: 340048e3ca98ddd003618449f331a120cce850a3 [file] [log] [blame]
Bram Moolenaar296b1f22017-01-15 15:22:33 +01001" Test Vim profiler
Bram Moolenaarb0f94c12019-06-13 22:19:53 +02002
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02003source check.vim
4CheckFeature profile
Bram Moolenaar296b1f22017-01-15 15:22:33 +01005
Bram Moolenaar93344c22019-08-14 21:12:05 +02006source shared.vim
Bram Moolenaar16358802019-08-30 18:37:26 +02007source screendump.vim
Bram Moolenaar93344c22019-08-14 21:12:05 +02008
Bram Moolenaar296b1f22017-01-15 15:22:33 +01009func Test_profile_func()
Bram Moolenaarb2049902021-01-24 12:53:53 +010010 call RunProfileFunc('func', 'let', 'let')
11 call RunProfileFunc('def', 'var', '')
12endfunc
13
14func RunProfileFunc(command, declare, assign)
Bram Moolenaarc79745a2019-05-20 22:12:34 +020015 let lines =<< trim [CODE]
16 profile start Xprofile_func.log
17 profile func Foo*
Bram Moolenaarb2049902021-01-24 12:53:53 +010018 XXX Foo1()
19 endXXX
20 XXX Foo2()
21 DDD counter = 100
22 while counter > 0
23 AAA counter = counter - 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +020024 endwhile
Bram Moolenaara21df1d2020-03-17 20:57:09 +010025 sleep 1m
Bram Moolenaarb2049902021-01-24 12:53:53 +010026 endXXX
27 XXX Foo3()
28 endXXX
29 XXX Bar()
30 endXXX
Bram Moolenaarc79745a2019-05-20 22:12:34 +020031 call Foo1()
32 call Foo1()
33 profile pause
34 call Foo1()
35 profile continue
36 call Foo2()
37 call Foo3()
38 call Bar()
39 if !v:profiling
40 delfunc Foo2
41 endif
42 delfunc Foo3
43 [CODE]
Bram Moolenaar296b1f22017-01-15 15:22:33 +010044
Bram Moolenaarb2049902021-01-24 12:53:53 +010045 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
46 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
47 call map(lines, {k, v -> substitute(v, 'AAA', a:assign, '') })
48
Bram Moolenaar296b1f22017-01-15 15:22:33 +010049 call writefile(lines, 'Xprofile_func.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +020050 call system(GetVimCommand()
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +020051 \ . ' -es --clean'
Bram Moolenaarc011a3d2017-01-16 22:37:42 +010052 \ . ' -c "so Xprofile_func.vim"'
53 \ . ' -c "qall!"')
54 call assert_equal(0, v:shell_error)
55
Bram Moolenaar296b1f22017-01-15 15:22:33 +010056 let lines = readfile('Xprofile_func.log')
57
Bram Moolenaar296b1f22017-01-15 15:22:33 +010058 " - Foo1() is called 3 times but should be reported as called twice
59 " since one call is in between "profile pause" .. "profile continue".
Bram Moolenaarc011a3d2017-01-16 22:37:42 +010060 " - Foo2() should come before Foo1() since Foo1() does much more work.
Bram Moolenaar296b1f22017-01-15 15:22:33 +010061 " - Foo3() is not reported because function is deleted.
62 " - Unlike Foo3(), Foo2() should not be deleted since there is a check
63 " for v:profiling.
64 " - Bar() is not reported since it does not match "profile func Foo*".
Bram Moolenaara21df1d2020-03-17 20:57:09 +010065 call assert_equal(31, len(lines))
Bram Moolenaarc011a3d2017-01-16 22:37:42 +010066
67 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar181d4f52019-09-18 22:04:56 +020068 call assert_match('Defined:.*Xprofile_func.vim:3', lines[1])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +020069 call assert_equal('Called 2 times', lines[2])
70 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
71 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
72 call assert_equal('', lines[5])
73 call assert_equal('count total (s) self (s)', lines[6])
74 call assert_equal('', lines[7])
75 call assert_equal('FUNCTION Foo2()', lines[8])
76 call assert_equal('Called 1 time', lines[10])
77 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[11])
78 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[12])
79 call assert_equal('', lines[13])
80 call assert_equal('count total (s) self (s)', lines[14])
Bram Moolenaarb2049902021-01-24 12:53:53 +010081 call assert_match('^\s*1\s\+.*\s\(let\|var\) counter = 100$', lines[15])
82 call assert_match('^\s*101\s\+.*\swhile counter > 0$', lines[16])
83 call assert_match('^\s*100\s\+.*\s \(let\)\= counter = counter - 1$', lines[17])
84 call assert_match('^\s*10[01]\s\+.*\sendwhile$', lines[18])
Bram Moolenaara21df1d2020-03-17 20:57:09 +010085 call assert_match('^\s*1\s\+.\+sleep 1m$', lines[19])
86 call assert_equal('', lines[20])
87 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[21])
88 call assert_equal('count total (s) self (s) function', lines[22])
89 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[23])
90 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[24])
91 call assert_equal('', lines[25])
92 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[26])
93 call assert_equal('count total (s) self (s) function', lines[27])
94 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[28])
95 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[29])
96 call assert_equal('', lines[30])
Bram Moolenaar296b1f22017-01-15 15:22:33 +010097
98 call delete('Xprofile_func.vim')
99 call delete('Xprofile_func.log')
100endfunc
101
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200102func Test_profile_func_with_ifelse()
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100103 call Run_profile_func_with_ifelse('func', 'let')
104 call Run_profile_func_with_ifelse('def', 'var')
Bram Moolenaarced68a02021-01-24 17:53:47 +0100105endfunc
106
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100107func Run_profile_func_with_ifelse(command, declare)
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200108 let lines =<< trim [CODE]
Bram Moolenaarced68a02021-01-24 17:53:47 +0100109 XXX Foo1()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200110 if 1
Bram Moolenaarced68a02021-01-24 17:53:47 +0100111 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200112 elseif 1
Bram Moolenaarced68a02021-01-24 17:53:47 +0100113 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200114 else
Bram Moolenaarced68a02021-01-24 17:53:47 +0100115 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200116 endif
Bram Moolenaarced68a02021-01-24 17:53:47 +0100117 endXXX
118 XXX Foo2()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200119 if 0
Bram Moolenaarced68a02021-01-24 17:53:47 +0100120 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200121 elseif 1
Bram Moolenaarced68a02021-01-24 17:53:47 +0100122 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200123 else
Bram Moolenaarced68a02021-01-24 17:53:47 +0100124 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200125 endif
Bram Moolenaarced68a02021-01-24 17:53:47 +0100126 endXXX
127 XXX Foo3()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200128 if 0
Bram Moolenaarced68a02021-01-24 17:53:47 +0100129 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200130 elseif 0
Bram Moolenaarced68a02021-01-24 17:53:47 +0100131 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200132 else
Bram Moolenaarced68a02021-01-24 17:53:47 +0100133 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200134 endif
Bram Moolenaarced68a02021-01-24 17:53:47 +0100135 endXXX
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200136 call Foo1()
137 call Foo2()
138 call Foo3()
139 [CODE]
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200140
Bram Moolenaarced68a02021-01-24 17:53:47 +0100141 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
142 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
Bram Moolenaarced68a02021-01-24 17:53:47 +0100143
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200144 call writefile(lines, 'Xprofile_func.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200145 call system(GetVimCommand()
146 \ . ' -es -i NONE --noplugin'
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200147 \ . ' -c "profile start Xprofile_func.log"'
148 \ . ' -c "profile func Foo*"'
149 \ . ' -c "so Xprofile_func.vim"'
150 \ . ' -c "qall!"')
151 call assert_equal(0, v:shell_error)
152
153 let lines = readfile('Xprofile_func.log')
154
155 " - Foo1() should pass 'if' block.
156 " - Foo2() should pass 'elseif' block.
157 " - Foo3() should pass 'else' block.
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200158 call assert_equal(57, len(lines))
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200159
160 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200161 call assert_match('Defined:.*Xprofile_func.vim', lines[1])
162 call assert_equal('Called 1 time', lines[2])
163 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
164 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
165 call assert_equal('', lines[5])
166 call assert_equal('count total (s) self (s)', lines[6])
167 call assert_match('^\s*1\s\+.*\sif 1$', lines[7])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100168 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200169 call assert_match( '^\s\+elseif 1$', lines[9])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100170 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[10])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200171 call assert_match( '^\s\+else$', lines[11])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100172 call assert_match( '^\s\+\(let\|var\) x = 2$', lines[12])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200173 call assert_match('^\s*1\s\+.*\sendif$', lines[13])
174 call assert_equal('', lines[14])
175 call assert_equal('FUNCTION Foo2()', lines[15])
176 call assert_equal('Called 1 time', lines[17])
177 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
178 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
179 call assert_equal('', lines[20])
180 call assert_equal('count total (s) self (s)', lines[21])
181 call assert_match('^\s*1\s\+.*\sif 0$', lines[22])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100182 call assert_match( '^\s\+\(let\|var\) x = 0$', lines[23])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200183 call assert_match('^\s*1\s\+.*\selseif 1$', lines[24])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100184 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 1$', lines[25])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200185 call assert_match( '^\s\+else$', lines[26])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100186 call assert_match( '^\s\+\(let\|var\) x = 2$', lines[27])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200187 call assert_match('^\s*1\s\+.*\sendif$', lines[28])
188 call assert_equal('', lines[29])
189 call assert_equal('FUNCTION Foo3()', lines[30])
190 call assert_equal('Called 1 time', lines[32])
191 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
192 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
193 call assert_equal('', lines[35])
194 call assert_equal('count total (s) self (s)', lines[36])
195 call assert_match('^\s*1\s\+.*\sif 0$', lines[37])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100196 call assert_match( '^\s\+\(let\|var\) x = 0$', lines[38])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200197 call assert_match('^\s*1\s\+.*\selseif 0$', lines[39])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100198 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[40])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200199 call assert_match('^\s*1\s\+.*\selse$', lines[41])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100200 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[42])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200201 call assert_match('^\s*1\s\+.*\sendif$', lines[43])
202 call assert_equal('', lines[44])
203 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
204 call assert_equal('count total (s) self (s) function', lines[46])
205 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
206 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
207 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
208 call assert_equal('', lines[50])
209 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
210 call assert_equal('count total (s) self (s) function', lines[52])
211 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
212 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
213 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
214 call assert_equal('', lines[56])
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200215
216 call delete('Xprofile_func.vim')
217 call delete('Xprofile_func.log')
218endfunc
219
220func Test_profile_func_with_trycatch()
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100221 call Run_profile_func_with_trycatch('func', 'let')
222 call Run_profile_func_with_trycatch('def', 'var')
223endfunc
224
225func Run_profile_func_with_trycatch(command, declare)
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200226 let lines =<< trim [CODE]
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100227 XXX Foo1()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200228 try
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100229 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200230 catch
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100231 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200232 finally
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100233 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200234 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100235 endXXX
236 XXX Foo2()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200237 try
238 throw 0
239 catch
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100240 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200241 finally
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100242 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200243 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100244 endXXX
245 XXX Foo3()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200246 try
247 throw 0
248 catch
249 throw 1
250 finally
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100251 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200252 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100253 endXXX
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200254 call Foo1()
255 call Foo2()
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100256 let rethrown = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200257 try
258 call Foo3()
259 catch
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100260 let rethrown = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200261 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100262 if rethrown != 1
263 " call Foo1 again so that the test fails
264 call Foo1()
265 endif
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200266 [CODE]
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200267
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100268 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
269 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
270
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200271 call writefile(lines, 'Xprofile_func.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200272 call system(GetVimCommand()
273 \ . ' -es -i NONE --noplugin'
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200274 \ . ' -c "profile start Xprofile_func.log"'
275 \ . ' -c "profile func Foo*"'
276 \ . ' -c "so Xprofile_func.vim"'
277 \ . ' -c "qall!"')
278 call assert_equal(0, v:shell_error)
279
280 let lines = readfile('Xprofile_func.log')
281
282 " - Foo1() should pass 'try' 'finally' blocks.
283 " - Foo2() should pass 'catch' 'finally' blocks.
284 " - Foo3() should not pass 'endtry'.
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200285 call assert_equal(57, len(lines))
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200286
287 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200288 call assert_match('Defined:.*Xprofile_func.vim', lines[1])
289 call assert_equal('Called 1 time', lines[2])
290 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
291 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
292 call assert_equal('', lines[5])
293 call assert_equal('count total (s) self (s)', lines[6])
294 call assert_match('^\s*1\s\+.*\stry$', lines[7])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100295 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200296 call assert_match( '^\s\+catch$', lines[9])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100297 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[10])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200298 call assert_match('^\s*1\s\+.*\sfinally$', lines[11])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100299 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[12])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200300 call assert_match('^\s*1\s\+.*\sendtry$', lines[13])
301 call assert_equal('', lines[14])
302 call assert_equal('FUNCTION Foo2()', lines[15])
303 call assert_equal('Called 1 time', lines[17])
304 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
305 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
306 call assert_equal('', lines[20])
307 call assert_equal('count total (s) self (s)', lines[21])
308 call assert_match('^\s*1\s\+.*\stry$', lines[22])
309 call assert_match('^\s*1\s\+.*\s throw 0$', lines[23])
310 call assert_match('^\s*1\s\+.*\scatch$', lines[24])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100311 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 1$', lines[25])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200312 call assert_match('^\s*1\s\+.*\sfinally$', lines[26])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100313 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[27])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200314 call assert_match('^\s*1\s\+.*\sendtry$', lines[28])
315 call assert_equal('', lines[29])
316 call assert_equal('FUNCTION Foo3()', lines[30])
317 call assert_equal('Called 1 time', lines[32])
318 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
319 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
320 call assert_equal('', lines[35])
321 call assert_equal('count total (s) self (s)', lines[36])
322 call assert_match('^\s*1\s\+.*\stry$', lines[37])
323 call assert_match('^\s*1\s\+.*\s throw 0$', lines[38])
324 call assert_match('^\s*1\s\+.*\scatch$', lines[39])
325 call assert_match('^\s*1\s\+.*\s throw 1$', lines[40])
326 call assert_match('^\s*1\s\+.*\sfinally$', lines[41])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100327 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[42])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200328 call assert_match( '^\s\+endtry$', lines[43])
329 call assert_equal('', lines[44])
330 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
331 call assert_equal('count total (s) self (s) function', lines[46])
332 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
333 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
334 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
335 call assert_equal('', lines[50])
336 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
337 call assert_equal('count total (s) self (s) function', lines[52])
338 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
339 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
340 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
341 call assert_equal('', lines[56])
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200342
343 call delete('Xprofile_func.vim')
344 call delete('Xprofile_func.log')
345endfunc
346
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100347func Test_profile_file()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200348 let lines =<< trim [CODE]
Bram Moolenaare7eb9272019-06-24 00:58:07 +0200349 func! Foo()
350 endfunc
351 for i in range(10)
352 " a comment
353 call Foo()
354 endfor
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200355 call Foo()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200356 [CODE]
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100357
358 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200359 call system(GetVimCommandClean()
360 \ . ' -es'
Bram Moolenaarc011a3d2017-01-16 22:37:42 +0100361 \ . ' -c "profile start Xprofile_file.log"'
362 \ . ' -c "profile file Xprofile_file.vim"'
363 \ . ' -c "so Xprofile_file.vim"'
364 \ . ' -c "so Xprofile_file.vim"'
365 \ . ' -c "qall!"')
366 call assert_equal(0, v:shell_error)
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100367
368 let lines = readfile('Xprofile_file.log')
369
370 call assert_equal(14, len(lines))
371
372 call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
373 call assert_equal('Sourced 2 times', lines[1])
374 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
375 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
376 call assert_equal('', lines[4])
377 call assert_equal('count total (s) self (s)', lines[5])
Bram Moolenaar67435d92017-10-19 21:04:37 +0200378 call assert_match(' 2 0.\d\+ func! Foo()', lines[6])
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100379 call assert_equal(' endfunc', lines[7])
380 " Loop iterates 10 times. Since script runs twice, body executes 20 times.
381 " First line of loop executes one more time than body to detect end of loop.
382 call assert_match('^\s*22\s\+\d\+\.\d\+\s\+for i in range(10)$', lines[8])
383 call assert_equal(' " a comment', lines[9])
Bram Moolenaard21b16f2017-08-14 23:13:30 +0200384 " if self and total are equal we only get one number
385 call assert_match('^\s*20\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[10])
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200386 call assert_match('^\s*22\s\+\d\+\.\d\+\s\+endfor$', lines[11])
Bram Moolenaare32bbde2017-01-15 21:12:48 +0100387 " if self and total are equal we only get one number
388 call assert_match('^\s*2\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[12])
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100389 call assert_equal('', lines[13])
390
391 call delete('Xprofile_file.vim')
392 call delete('Xprofile_file.log')
393endfunc
394
Bram Moolenaar67435d92017-10-19 21:04:37 +0200395func Test_profile_file_with_cont()
396 let lines = [
397 \ 'echo "hello',
398 \ ' \ world"',
399 \ 'echo "foo ',
400 \ ' \bar"',
401 \ ]
402
403 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200404 call system(GetVimCommandClean()
405 \ . ' -es'
Bram Moolenaar67435d92017-10-19 21:04:37 +0200406 \ . ' -c "profile start Xprofile_file.log"'
407 \ . ' -c "profile file Xprofile_file.vim"'
408 \ . ' -c "so Xprofile_file.vim"'
409 \ . ' -c "qall!"')
410 call assert_equal(0, v:shell_error)
411
412 let lines = readfile('Xprofile_file.log')
413 call assert_equal(11, len(lines))
414
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200415 call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
416 call assert_equal('Sourced 1 time', lines[1])
417 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
418 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
419 call assert_equal('', lines[4])
420 call assert_equal('count total (s) self (s)', lines[5])
421 call assert_match(' 1 0.\d\+ echo "hello', lines[6])
422 call assert_equal(' \ world"', lines[7])
423 call assert_match(' 1 0.\d\+ echo "foo ', lines[8])
424 call assert_equal(' \bar"', lines[9])
425 call assert_equal('', lines[10])
Bram Moolenaar67435d92017-10-19 21:04:37 +0200426
427 call delete('Xprofile_file.vim')
428 call delete('Xprofile_file.log')
429endfunc
430
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100431" Test for ':profile stop' and ':profile dump' commands
432func Test_profile_stop_dump()
433 call delete('Xprof1.out')
434 call delete('Xprof2.out')
435 call delete('Xprof3.out')
436 func Xprof_test1()
437 return "Hello"
438 endfunc
439 func Xprof_test2()
440 return "World"
441 endfunc
442
443 " Test for ':profile stop'
444 profile start Xprof1.out
445 profile func Xprof_test1
446 call Xprof_test1()
447 profile stop
448
449 let lines = readfile('Xprof1.out')
450 call assert_equal(17, len(lines))
451 call assert_equal('FUNCTION Xprof_test1()', lines[0])
452 call assert_match('Defined:.*test_profile.vim:', lines[1])
453 call assert_equal('Called 1 time', lines[2])
454 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
455 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
456 call assert_equal('', lines[5])
457 call assert_equal('count total (s) self (s)', lines[6])
458 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
459 call assert_equal('', lines[8])
460 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
461 call assert_equal('count total (s) self (s) function', lines[10])
462 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[11])
463 call assert_equal('', lines[12])
464 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
465 call assert_equal('count total (s) self (s) function', lines[14])
466 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[15])
467 call assert_equal('', lines[16])
468
469 " Test for ':profile stop' for a different function
470 profile start Xprof2.out
471 profile func Xprof_test2
472 call Xprof_test2()
473 profile stop
474 let lines = readfile('Xprof2.out')
475 call assert_equal(17, len(lines))
476 call assert_equal('FUNCTION Xprof_test2()', lines[0])
477 call assert_match('Defined:.*test_profile.vim:', lines[1])
478 call assert_equal('Called 1 time', lines[2])
479 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
480 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
481 call assert_equal('', lines[5])
482 call assert_equal('count total (s) self (s)', lines[6])
483 call assert_match('^\s*1\s\+.*\sreturn "World"$', lines[7])
484 call assert_equal('', lines[8])
485 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
486 call assert_equal('count total (s) self (s) function', lines[10])
487 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[11])
488 call assert_equal('', lines[12])
489 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
490 call assert_equal('count total (s) self (s) function', lines[14])
491 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[15])
492 call assert_equal('', lines[16])
493
494 " Test for ':profile dump'
495 profile start Xprof3.out
496 profile func Xprof_test1
497 profile func Xprof_test2
498 call Xprof_test1()
499 profile dump
500 " dump the profile once and verify the contents
501 let lines = readfile('Xprof3.out')
502 call assert_equal(17, len(lines))
503 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
504 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[11])
505 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[15])
506 " dump the profile again and verify the contents
507 call Xprof_test2()
508 profile dump
509 profile stop
510 let lines = readfile('Xprof3.out')
511 call assert_equal(28, len(lines))
512 call assert_equal('FUNCTION Xprof_test1()', lines[0])
513 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
514 call assert_equal('FUNCTION Xprof_test2()', lines[9])
515 call assert_match('^\s*1\s\+.*\sreturn "World"$', lines[16])
516
517 delfunc Xprof_test1
518 delfunc Xprof_test2
519 call delete('Xprof1.out')
520 call delete('Xprof2.out')
521 call delete('Xprof3.out')
522endfunc
523
524" Test for :profile sub-command completion
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100525func Test_profile_completion()
526 call feedkeys(":profile \<C-A>\<C-B>\"\<CR>", 'tx')
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100527 call assert_equal('"profile continue dump file func pause start stop', @:)
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100528
529 call feedkeys(":profile start test_prof\<C-A>\<C-B>\"\<CR>", 'tx')
530 call assert_match('^"profile start.* test_profile\.vim', @:)
Yegappan Lakshmanan1fdf84e2022-03-15 10:53:09 +0000531
532 call feedkeys(":profile file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
533 call assert_match('"profile file test_profile\.vim', @:)
534 call feedkeys(":profile file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
535 call assert_match('"profile file test_profile\.vim', @:)
536 call feedkeys(":profile file test_prof \<Tab>\<C-B>\"\<CR>", 'tx')
537 call assert_match('"profile file test_prof ', @:)
538 call feedkeys(":profile file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
539 call assert_match('"profile file X1B2C3', @:)
540
541 func Xprof_test()
542 endfunc
543 call feedkeys(":profile func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
544 call assert_equal('"profile func Xprof_test', @:)
545 call feedkeys(":profile func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
546 call assert_equal('"profile func Xprof_test', @:)
547 call feedkeys(":profile func Xprof \<Tab>\<C-B>\"\<CR>", 'tx')
548 call assert_equal('"profile func Xprof ', @:)
549 call feedkeys(":profile func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
550 call assert_equal('"profile func X1B2C3', @:)
551
552 call feedkeys(":profdel \<C-A>\<C-B>\"\<CR>", 'tx')
553 call assert_equal('"profdel file func', @:)
554 call feedkeys(":profdel fu\<Tab>\<C-B>\"\<CR>", 'tx')
555 call assert_equal('"profdel func', @:)
556 call feedkeys(":profdel he\<Tab>\<C-B>\"\<CR>", 'tx')
557 call assert_equal('"profdel he', @:)
558 call feedkeys(":profdel here \<Tab>\<C-B>\"\<CR>", 'tx')
559 call assert_equal('"profdel here ', @:)
560 call feedkeys(":profdel file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
561 call assert_equal('"profdel file test_profile.vim', @:)
562 call feedkeys(":profdel file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
563 call assert_equal('"profdel file X1B2C3', @:)
564 call feedkeys(":profdel func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
565 call assert_equal('"profdel func Xprof_test', @:)
566 call feedkeys(":profdel func Xprof_test \<Tab>\<C-B>\"\<CR>", 'tx')
567 call assert_equal('"profdel func Xprof_test ', @:)
568 call feedkeys(":profdel func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
569 call assert_equal('"profdel func X1B2C3', @:)
570
571 delfunc Xprof_test
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100572endfunc
573
574func Test_profile_errors()
575 call assert_fails("profile func Foo", 'E750:')
576 call assert_fails("profile pause", 'E750:')
577 call assert_fails("profile continue", 'E750:')
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100578 call assert_fails("profile stop", 'E750:')
579 call assert_fails("profile dump", 'E750:')
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100580endfunc
Bram Moolenaarac112f02017-12-05 16:46:28 +0100581
582func Test_profile_truncate_mbyte()
Bram Moolenaar30276f22019-01-24 17:59:39 +0100583 if &enc !=# 'utf-8'
Bram Moolenaarac112f02017-12-05 16:46:28 +0100584 return
585 endif
586
587 let lines = [
588 \ 'scriptencoding utf-8',
589 \ 'func! Foo()',
590 \ ' return [',
591 \ ' \ "' . join(map(range(0x4E00, 0x4E00 + 340), 'nr2char(v:val)'), '') . '",',
592 \ ' \ "' . join(map(range(0x4F00, 0x4F00 + 340), 'nr2char(v:val)'), '') . '",',
593 \ ' \ ]',
594 \ 'endfunc',
595 \ 'call Foo()',
596 \ ]
597
598 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200599 call system(GetVimCommandClean()
600 \ . ' -es --cmd "set enc=utf-8"'
Bram Moolenaarac112f02017-12-05 16:46:28 +0100601 \ . ' -c "profile start Xprofile_file.log"'
602 \ . ' -c "profile file Xprofile_file.vim"'
603 \ . ' -c "so Xprofile_file.vim"'
604 \ . ' -c "qall!"')
605 call assert_equal(0, v:shell_error)
606
607 split Xprofile_file.log
608 if &fenc != ''
609 call assert_equal('utf-8', &fenc)
610 endif
611 /func! Foo()
612 let lnum = line('.')
613 call assert_match('^\s*return \[$', getline(lnum + 1))
614 call assert_match("\u4F52$", getline(lnum + 2))
615 call assert_match("\u5052$", getline(lnum + 3))
616 call assert_match('^\s*\\ \]$', getline(lnum + 4))
617 bwipe!
618
619 call delete('Xprofile_file.vim')
620 call delete('Xprofile_file.log')
621endfunc
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200622
623func Test_profdel_func()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200624 let lines =<< trim [CODE]
625 profile start Xprofile_file.log
626 func! Foo1()
627 endfunc
628 func! Foo2()
629 endfunc
630 func! Foo3()
631 endfunc
632
633 profile func Foo1
634 profile func Foo2
635 call Foo1()
636 call Foo2()
637
638 profile func Foo3
639 profdel func Foo2
640 profdel func Foo3
641 call Foo1()
642 call Foo2()
643 call Foo3()
644 [CODE]
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200645 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200646 call system(GetVimCommandClean() . ' -es -c "so Xprofile_file.vim" -c q')
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200647 call assert_equal(0, v:shell_error)
648
649 let lines = readfile('Xprofile_file.log')
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200650 call assert_equal(26, len(lines))
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200651
652 " Check that:
653 " - Foo1() is called twice (profdel not invoked)
654 " - Foo2() is called once (profdel invoked after it was called)
655 " - Foo3() is not called (profdel invoked before it was called)
656 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200657 call assert_match('Defined:.*Xprofile_file.vim', lines[1])
658 call assert_equal('Called 2 times', lines[2])
659 call assert_equal('FUNCTION Foo2()', lines[8])
660 call assert_equal('Called 1 time', lines[10])
661 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[16])
662 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[21])
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200663
664 call delete('Xprofile_file.vim')
665 call delete('Xprofile_file.log')
666endfunc
667
668func Test_profdel_star()
669 " Foo() is invoked once before and once after 'profdel *'.
670 " So profiling should report it only once.
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200671 let lines =<< trim [CODE]
672 profile start Xprofile_file.log
673 func! Foo()
674 endfunc
675 profile func Foo
676 call Foo()
677 profdel *
678 call Foo()
679 [CODE]
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200680 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200681 call system(GetVimCommandClean() . ' -es -c "so Xprofile_file.vim" -c q')
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200682 call assert_equal(0, v:shell_error)
683
684 let lines = readfile('Xprofile_file.log')
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200685 call assert_equal(16, len(lines))
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200686
687 call assert_equal('FUNCTION Foo()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200688 call assert_match('Defined:.*Xprofile_file.vim', lines[1])
689 call assert_equal('Called 1 time', lines[2])
690 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[8])
691 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[12])
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200692
693 call delete('Xprofile_file.vim')
694 call delete('Xprofile_file.log')
695endfunc
Bram Moolenaar16358802019-08-30 18:37:26 +0200696
697" When typing the function it won't have a script ID, test that this works.
698func Test_profile_typed_func()
699 CheckScreendump
700
701 let lines =<< trim END
702 profile start XprofileTypedFunc
703 END
704 call writefile(lines, 'XtestProfile')
705 let buf = RunVimInTerminal('-S XtestProfile', #{})
706
707 call term_sendkeys(buf, ":func DoSomething()\<CR>"
708 \ .. "echo 'hello'\<CR>"
709 \ .. "endfunc\<CR>")
710 call term_sendkeys(buf, ":profile func DoSomething\<CR>")
711 call term_sendkeys(buf, ":call DoSomething()\<CR>")
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200712 call TermWait(buf, 100)
Bram Moolenaar16358802019-08-30 18:37:26 +0200713 call StopVimInTerminal(buf)
714 let lines = readfile('XprofileTypedFunc')
715 call assert_equal("FUNCTION DoSomething()", lines[0])
716 call assert_equal("Called 1 time", lines[1])
717
718 " clean up
719 call delete('XprofileTypedFunc')
720 call delete('XtestProfile')
721endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200722
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100723func Test_vim9_profiling()
724 " only tests that compiling and calling functions doesn't crash
725 let lines =<< trim END
726 vim9script
727 def Func()
728 Crash()
729 enddef
730 def Crash()
731 enddef
Bram Moolenaar98989a02021-01-26 12:06:30 +0100732 prof start Xprofile_crash.log
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100733 prof func Func
734 Func()
735 END
Bram Moolenaar98989a02021-01-26 12:06:30 +0100736 call writefile(lines, 'Xprofile_crash.vim')
737 call system(GetVimCommandClean() . ' -es -c "so Xprofile_crash.vim" -c q')
738 call assert_equal(0, v:shell_error)
Bram Moolenaar8c801b32021-03-05 20:58:22 +0100739 call assert_true(readfile('Xprofile_crash.log')->len() > 10)
Bram Moolenaar98989a02021-01-26 12:06:30 +0100740 call delete('Xprofile_crash.vim')
741 call delete('Xprofile_crash.log')
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100742endfunc
743
Bram Moolenaar12d26532021-02-19 19:13:21 +0100744func Test_vim9_nested_call()
745 let lines =<< trim END
746 vim9script
747 var total = 0
748 def One(Ref: func(number))
749 for i in range(3)
750 Ref(i)
751 endfor
752 enddef
753 def Two(nr: number)
754 total += nr
755 enddef
756 prof start Xprofile_nested.log
757 prof func One
758 prof func Two
759 One((nr) => Two(nr))
760 assert_equal(3, total)
761 END
762 call writefile(lines, 'Xprofile_nested.vim')
763 call system(GetVimCommandClean() . ' -es -c "so Xprofile_nested.vim" -c q')
764 call assert_equal(0, v:shell_error)
765
766 let prof_lines = readfile('Xprofile_nested.log')->join('#')
767 call assert_match('FUNCTION <SNR>\d\+_One().*'
768 \ .. '#Called 1 time.*'
769 \ .. '# 1 \s*[0-9.]\+ for i in range(3)'
770 \ .. '# 3 \s*[0-9.]\+ \s*[0-9.]\+ Ref(i)'
771 \ .. '# 3 \s*[0-9.]\+ endfor', prof_lines)
772 call assert_match('FUNCTION <SNR>\d\+_Two().*'
773 \ .. '#Called 3 times.*'
774 \ .. '# 3 \s*[0-9.]\+ total += nr', prof_lines)
Bram Moolenaar4fa11752021-03-03 13:26:02 +0100775 call delete('Xprofile_nested.vim')
776 call delete('Xprofile_nested.log')
Bram Moolenaar12d26532021-02-19 19:13:21 +0100777endfunc
778
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100779
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200780" vim: shiftwidth=2 sts=2 expandtab