blob: 47ff2a2dd7ec8445af44ffcf8d1bcb85aeb4083f [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
K.Takata0500e872022-09-08 12:28:02 +010056 sleep 50m
Bram Moolenaar296b1f22017-01-15 15:22:33 +010057 let lines = readfile('Xprofile_func.log')
58
Bram Moolenaar296b1f22017-01-15 15:22:33 +010059 " - Foo1() is called 3 times but should be reported as called twice
60 " since one call is in between "profile pause" .. "profile continue".
Bram Moolenaarc011a3d2017-01-16 22:37:42 +010061 " - Foo2() should come before Foo1() since Foo1() does much more work.
Bram Moolenaar296b1f22017-01-15 15:22:33 +010062 " - Foo3() is not reported because function is deleted.
63 " - Unlike Foo3(), Foo2() should not be deleted since there is a check
64 " for v:profiling.
65 " - Bar() is not reported since it does not match "profile func Foo*".
Bram Moolenaara21df1d2020-03-17 20:57:09 +010066 call assert_equal(31, len(lines))
Bram Moolenaarc011a3d2017-01-16 22:37:42 +010067
68 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar181d4f52019-09-18 22:04:56 +020069 call assert_match('Defined:.*Xprofile_func.vim:3', lines[1])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +020070 call assert_equal('Called 2 times', lines[2])
71 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
72 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
73 call assert_equal('', lines[5])
74 call assert_equal('count total (s) self (s)', lines[6])
75 call assert_equal('', lines[7])
76 call assert_equal('FUNCTION Foo2()', lines[8])
77 call assert_equal('Called 1 time', lines[10])
78 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[11])
79 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[12])
80 call assert_equal('', lines[13])
81 call assert_equal('count total (s) self (s)', lines[14])
Bram Moolenaarb2049902021-01-24 12:53:53 +010082 call assert_match('^\s*1\s\+.*\s\(let\|var\) counter = 100$', lines[15])
83 call assert_match('^\s*101\s\+.*\swhile counter > 0$', lines[16])
84 call assert_match('^\s*100\s\+.*\s \(let\)\= counter = counter - 1$', lines[17])
85 call assert_match('^\s*10[01]\s\+.*\sendwhile$', lines[18])
Bram Moolenaara21df1d2020-03-17 20:57:09 +010086 call assert_match('^\s*1\s\+.\+sleep 1m$', lines[19])
87 call assert_equal('', lines[20])
88 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[21])
89 call assert_equal('count total (s) self (s) function', lines[22])
90 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[23])
91 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[24])
92 call assert_equal('', lines[25])
93 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[26])
94 call assert_equal('count total (s) self (s) function', lines[27])
95 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[28])
96 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[29])
97 call assert_equal('', lines[30])
Bram Moolenaar296b1f22017-01-15 15:22:33 +010098
99 call delete('Xprofile_func.vim')
100 call delete('Xprofile_func.log')
101endfunc
102
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200103func Test_profile_func_with_ifelse()
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100104 call Run_profile_func_with_ifelse('func', 'let')
105 call Run_profile_func_with_ifelse('def', 'var')
Bram Moolenaarced68a02021-01-24 17:53:47 +0100106endfunc
107
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100108func Run_profile_func_with_ifelse(command, declare)
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200109 let lines =<< trim [CODE]
Bram Moolenaarced68a02021-01-24 17:53:47 +0100110 XXX Foo1()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200111 if 1
Bram Moolenaarced68a02021-01-24 17:53:47 +0100112 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200113 elseif 1
Bram Moolenaarced68a02021-01-24 17:53:47 +0100114 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200115 else
Bram Moolenaarced68a02021-01-24 17:53:47 +0100116 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200117 endif
Bram Moolenaarced68a02021-01-24 17:53:47 +0100118 endXXX
119 XXX Foo2()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200120 if 0
Bram Moolenaarced68a02021-01-24 17:53:47 +0100121 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200122 elseif 1
Bram Moolenaarced68a02021-01-24 17:53:47 +0100123 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200124 else
Bram Moolenaarced68a02021-01-24 17:53:47 +0100125 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200126 endif
Bram Moolenaarced68a02021-01-24 17:53:47 +0100127 endXXX
128 XXX Foo3()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200129 if 0
Bram Moolenaarced68a02021-01-24 17:53:47 +0100130 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200131 elseif 0
Bram Moolenaarced68a02021-01-24 17:53:47 +0100132 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200133 else
Bram Moolenaarced68a02021-01-24 17:53:47 +0100134 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200135 endif
Bram Moolenaarced68a02021-01-24 17:53:47 +0100136 endXXX
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200137 call Foo1()
138 call Foo2()
139 call Foo3()
140 [CODE]
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200141
Bram Moolenaarced68a02021-01-24 17:53:47 +0100142 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
143 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
Bram Moolenaarced68a02021-01-24 17:53:47 +0100144
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200145 call writefile(lines, 'Xprofile_func.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200146 call system(GetVimCommand()
147 \ . ' -es -i NONE --noplugin'
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200148 \ . ' -c "profile start Xprofile_func.log"'
149 \ . ' -c "profile func Foo*"'
150 \ . ' -c "so Xprofile_func.vim"'
151 \ . ' -c "qall!"')
152 call assert_equal(0, v:shell_error)
153
154 let lines = readfile('Xprofile_func.log')
155
156 " - Foo1() should pass 'if' block.
157 " - Foo2() should pass 'elseif' block.
158 " - Foo3() should pass 'else' block.
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200159 call assert_equal(57, len(lines))
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200160
161 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200162 call assert_match('Defined:.*Xprofile_func.vim', lines[1])
163 call assert_equal('Called 1 time', lines[2])
164 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
165 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
166 call assert_equal('', lines[5])
167 call assert_equal('count total (s) self (s)', lines[6])
168 call assert_match('^\s*1\s\+.*\sif 1$', lines[7])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100169 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200170 call assert_match( '^\s\+elseif 1$', lines[9])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100171 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[10])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200172 call assert_match( '^\s\+else$', lines[11])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100173 call assert_match( '^\s\+\(let\|var\) x = 2$', lines[12])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200174 call assert_match('^\s*1\s\+.*\sendif$', lines[13])
175 call assert_equal('', lines[14])
176 call assert_equal('FUNCTION Foo2()', lines[15])
177 call assert_equal('Called 1 time', lines[17])
178 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
179 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
180 call assert_equal('', lines[20])
181 call assert_equal('count total (s) self (s)', lines[21])
182 call assert_match('^\s*1\s\+.*\sif 0$', lines[22])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100183 call assert_match( '^\s\+\(let\|var\) x = 0$', lines[23])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200184 call assert_match('^\s*1\s\+.*\selseif 1$', lines[24])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100185 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 1$', lines[25])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200186 call assert_match( '^\s\+else$', lines[26])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100187 call assert_match( '^\s\+\(let\|var\) x = 2$', lines[27])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200188 call assert_match('^\s*1\s\+.*\sendif$', lines[28])
189 call assert_equal('', lines[29])
190 call assert_equal('FUNCTION Foo3()', lines[30])
191 call assert_equal('Called 1 time', lines[32])
192 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
193 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
194 call assert_equal('', lines[35])
195 call assert_equal('count total (s) self (s)', lines[36])
196 call assert_match('^\s*1\s\+.*\sif 0$', lines[37])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100197 call assert_match( '^\s\+\(let\|var\) x = 0$', lines[38])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200198 call assert_match('^\s*1\s\+.*\selseif 0$', lines[39])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100199 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[40])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200200 call assert_match('^\s*1\s\+.*\selse$', lines[41])
Bram Moolenaarced68a02021-01-24 17:53:47 +0100201 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[42])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200202 call assert_match('^\s*1\s\+.*\sendif$', lines[43])
203 call assert_equal('', lines[44])
204 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
205 call assert_equal('count total (s) self (s) function', lines[46])
206 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
207 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
208 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
209 call assert_equal('', lines[50])
210 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
211 call assert_equal('count total (s) self (s) function', lines[52])
212 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
213 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
214 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
215 call assert_equal('', lines[56])
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200216
217 call delete('Xprofile_func.vim')
218 call delete('Xprofile_func.log')
219endfunc
220
221func Test_profile_func_with_trycatch()
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100222 call Run_profile_func_with_trycatch('func', 'let')
223 call Run_profile_func_with_trycatch('def', 'var')
224endfunc
225
226func Run_profile_func_with_trycatch(command, declare)
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200227 let lines =<< trim [CODE]
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100228 XXX Foo1()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200229 try
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100230 DDD x = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200231 catch
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100232 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200233 finally
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100234 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200235 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100236 endXXX
237 XXX Foo2()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200238 try
239 throw 0
240 catch
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100241 DDD x = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200242 finally
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100243 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200244 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100245 endXXX
246 XXX Foo3()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200247 try
248 throw 0
249 catch
250 throw 1
251 finally
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100252 DDD x = 2
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200253 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100254 endXXX
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200255 call Foo1()
256 call Foo2()
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100257 let rethrown = 0
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200258 try
259 call Foo3()
260 catch
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100261 let rethrown = 1
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200262 endtry
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100263 if rethrown != 1
264 " call Foo1 again so that the test fails
265 call Foo1()
266 endif
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200267 [CODE]
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200268
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100269 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
270 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
271
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200272 call writefile(lines, 'Xprofile_func.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200273 call system(GetVimCommand()
274 \ . ' -es -i NONE --noplugin'
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200275 \ . ' -c "profile start Xprofile_func.log"'
276 \ . ' -c "profile func Foo*"'
277 \ . ' -c "so Xprofile_func.vim"'
278 \ . ' -c "qall!"')
279 call assert_equal(0, v:shell_error)
280
281 let lines = readfile('Xprofile_func.log')
282
283 " - Foo1() should pass 'try' 'finally' blocks.
284 " - Foo2() should pass 'catch' 'finally' blocks.
285 " - Foo3() should not pass 'endtry'.
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200286 call assert_equal(57, len(lines))
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200287
288 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200289 call assert_match('Defined:.*Xprofile_func.vim', lines[1])
290 call assert_equal('Called 1 time', lines[2])
291 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
292 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
293 call assert_equal('', lines[5])
294 call assert_equal('count total (s) self (s)', lines[6])
295 call assert_match('^\s*1\s\+.*\stry$', lines[7])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100296 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200297 call assert_match( '^\s\+catch$', lines[9])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100298 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[10])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200299 call assert_match('^\s*1\s\+.*\sfinally$', lines[11])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100300 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[12])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200301 call assert_match('^\s*1\s\+.*\sendtry$', lines[13])
302 call assert_equal('', lines[14])
303 call assert_equal('FUNCTION Foo2()', lines[15])
304 call assert_equal('Called 1 time', lines[17])
305 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
306 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
307 call assert_equal('', lines[20])
308 call assert_equal('count total (s) self (s)', lines[21])
309 call assert_match('^\s*1\s\+.*\stry$', lines[22])
310 call assert_match('^\s*1\s\+.*\s throw 0$', lines[23])
311 call assert_match('^\s*1\s\+.*\scatch$', lines[24])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100312 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 1$', lines[25])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200313 call assert_match('^\s*1\s\+.*\sfinally$', lines[26])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100314 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[27])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200315 call assert_match('^\s*1\s\+.*\sendtry$', lines[28])
316 call assert_equal('', lines[29])
317 call assert_equal('FUNCTION Foo3()', lines[30])
318 call assert_equal('Called 1 time', lines[32])
319 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
320 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
321 call assert_equal('', lines[35])
322 call assert_equal('count total (s) self (s)', lines[36])
323 call assert_match('^\s*1\s\+.*\stry$', lines[37])
324 call assert_match('^\s*1\s\+.*\s throw 0$', lines[38])
325 call assert_match('^\s*1\s\+.*\scatch$', lines[39])
326 call assert_match('^\s*1\s\+.*\s throw 1$', lines[40])
327 call assert_match('^\s*1\s\+.*\sfinally$', lines[41])
Bram Moolenaar107e9ce2021-01-24 20:52:00 +0100328 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[42])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200329 call assert_match( '^\s\+endtry$', lines[43])
330 call assert_equal('', lines[44])
331 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
332 call assert_equal('count total (s) self (s) function', lines[46])
333 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
334 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
335 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
336 call assert_equal('', lines[50])
337 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
338 call assert_equal('count total (s) self (s) function', lines[52])
339 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
340 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
341 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
342 call assert_equal('', lines[56])
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200343
344 call delete('Xprofile_func.vim')
345 call delete('Xprofile_func.log')
346endfunc
347
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100348func Test_profile_file()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200349 let lines =<< trim [CODE]
Bram Moolenaare7eb9272019-06-24 00:58:07 +0200350 func! Foo()
351 endfunc
352 for i in range(10)
353 " a comment
354 call Foo()
355 endfor
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200356 call Foo()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200357 [CODE]
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100358
359 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200360 call system(GetVimCommandClean()
361 \ . ' -es'
Bram Moolenaarc011a3d2017-01-16 22:37:42 +0100362 \ . ' -c "profile start Xprofile_file.log"'
363 \ . ' -c "profile file Xprofile_file.vim"'
364 \ . ' -c "so Xprofile_file.vim"'
365 \ . ' -c "so Xprofile_file.vim"'
366 \ . ' -c "qall!"')
367 call assert_equal(0, v:shell_error)
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100368
369 let lines = readfile('Xprofile_file.log')
370
371 call assert_equal(14, len(lines))
372
373 call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
374 call assert_equal('Sourced 2 times', lines[1])
375 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
376 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
377 call assert_equal('', lines[4])
378 call assert_equal('count total (s) self (s)', lines[5])
Bram Moolenaar67435d92017-10-19 21:04:37 +0200379 call assert_match(' 2 0.\d\+ func! Foo()', lines[6])
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100380 call assert_equal(' endfunc', lines[7])
381 " Loop iterates 10 times. Since script runs twice, body executes 20 times.
382 " First line of loop executes one more time than body to detect end of loop.
383 call assert_match('^\s*22\s\+\d\+\.\d\+\s\+for i in range(10)$', lines[8])
384 call assert_equal(' " a comment', lines[9])
Bram Moolenaard21b16f2017-08-14 23:13:30 +0200385 " if self and total are equal we only get one number
386 call assert_match('^\s*20\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[10])
Bram Moolenaar7feb35e2018-08-21 17:49:54 +0200387 call assert_match('^\s*22\s\+\d\+\.\d\+\s\+endfor$', lines[11])
Bram Moolenaare32bbde2017-01-15 21:12:48 +0100388 " if self and total are equal we only get one number
389 call assert_match('^\s*2\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[12])
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100390 call assert_equal('', lines[13])
391
392 call delete('Xprofile_file.vim')
393 call delete('Xprofile_file.log')
394endfunc
395
Bram Moolenaar67435d92017-10-19 21:04:37 +0200396func Test_profile_file_with_cont()
397 let lines = [
398 \ 'echo "hello',
399 \ ' \ world"',
400 \ 'echo "foo ',
401 \ ' \bar"',
402 \ ]
403
404 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200405 call system(GetVimCommandClean()
406 \ . ' -es'
Bram Moolenaar67435d92017-10-19 21:04:37 +0200407 \ . ' -c "profile start Xprofile_file.log"'
408 \ . ' -c "profile file Xprofile_file.vim"'
409 \ . ' -c "so Xprofile_file.vim"'
410 \ . ' -c "qall!"')
411 call assert_equal(0, v:shell_error)
412
413 let lines = readfile('Xprofile_file.log')
414 call assert_equal(11, len(lines))
415
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200416 call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
417 call assert_equal('Sourced 1 time', lines[1])
418 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
419 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
420 call assert_equal('', lines[4])
421 call assert_equal('count total (s) self (s)', lines[5])
422 call assert_match(' 1 0.\d\+ echo "hello', lines[6])
423 call assert_equal(' \ world"', lines[7])
424 call assert_match(' 1 0.\d\+ echo "foo ', lines[8])
425 call assert_equal(' \bar"', lines[9])
426 call assert_equal('', lines[10])
Bram Moolenaar67435d92017-10-19 21:04:37 +0200427
428 call delete('Xprofile_file.vim')
429 call delete('Xprofile_file.log')
430endfunc
431
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100432" Test for ':profile stop' and ':profile dump' commands
433func Test_profile_stop_dump()
434 call delete('Xprof1.out')
435 call delete('Xprof2.out')
436 call delete('Xprof3.out')
437 func Xprof_test1()
438 return "Hello"
439 endfunc
440 func Xprof_test2()
441 return "World"
442 endfunc
443
444 " Test for ':profile stop'
445 profile start Xprof1.out
446 profile func Xprof_test1
447 call Xprof_test1()
448 profile stop
449
450 let lines = readfile('Xprof1.out')
451 call assert_equal(17, len(lines))
452 call assert_equal('FUNCTION Xprof_test1()', lines[0])
453 call assert_match('Defined:.*test_profile.vim:', lines[1])
454 call assert_equal('Called 1 time', lines[2])
455 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
456 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
457 call assert_equal('', lines[5])
458 call assert_equal('count total (s) self (s)', lines[6])
459 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
460 call assert_equal('', lines[8])
461 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
462 call assert_equal('count total (s) self (s) function', lines[10])
463 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[11])
464 call assert_equal('', lines[12])
465 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
466 call assert_equal('count total (s) self (s) function', lines[14])
467 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[15])
468 call assert_equal('', lines[16])
469
470 " Test for ':profile stop' for a different function
471 profile start Xprof2.out
472 profile func Xprof_test2
473 call Xprof_test2()
474 profile stop
475 let lines = readfile('Xprof2.out')
476 call assert_equal(17, len(lines))
477 call assert_equal('FUNCTION Xprof_test2()', lines[0])
478 call assert_match('Defined:.*test_profile.vim:', lines[1])
479 call assert_equal('Called 1 time', lines[2])
480 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
481 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
482 call assert_equal('', lines[5])
483 call assert_equal('count total (s) self (s)', lines[6])
484 call assert_match('^\s*1\s\+.*\sreturn "World"$', lines[7])
485 call assert_equal('', lines[8])
486 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
487 call assert_equal('count total (s) self (s) function', lines[10])
488 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[11])
489 call assert_equal('', lines[12])
490 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
491 call assert_equal('count total (s) self (s) function', lines[14])
492 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[15])
493 call assert_equal('', lines[16])
494
495 " Test for ':profile dump'
496 profile start Xprof3.out
497 profile func Xprof_test1
498 profile func Xprof_test2
499 call Xprof_test1()
500 profile dump
501 " dump the profile once and verify the contents
502 let lines = readfile('Xprof3.out')
503 call assert_equal(17, len(lines))
504 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
505 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[11])
506 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[15])
507 " dump the profile again and verify the contents
508 call Xprof_test2()
509 profile dump
510 profile stop
511 let lines = readfile('Xprof3.out')
512 call assert_equal(28, len(lines))
513 call assert_equal('FUNCTION Xprof_test1()', lines[0])
514 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
515 call assert_equal('FUNCTION Xprof_test2()', lines[9])
516 call assert_match('^\s*1\s\+.*\sreturn "World"$', lines[16])
517
518 delfunc Xprof_test1
519 delfunc Xprof_test2
520 call delete('Xprof1.out')
521 call delete('Xprof2.out')
522 call delete('Xprof3.out')
523endfunc
524
525" Test for :profile sub-command completion
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100526func Test_profile_completion()
527 call feedkeys(":profile \<C-A>\<C-B>\"\<CR>", 'tx')
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100528 call assert_equal('"profile continue dump file func pause start stop', @:)
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100529
530 call feedkeys(":profile start test_prof\<C-A>\<C-B>\"\<CR>", 'tx')
531 call assert_match('^"profile start.* test_profile\.vim', @:)
Yegappan Lakshmanan1fdf84e2022-03-15 10:53:09 +0000532
533 call feedkeys(":profile file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
534 call assert_match('"profile file test_profile\.vim', @:)
535 call feedkeys(":profile file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
536 call assert_match('"profile file test_profile\.vim', @:)
537 call feedkeys(":profile file test_prof \<Tab>\<C-B>\"\<CR>", 'tx')
538 call assert_match('"profile file test_prof ', @:)
539 call feedkeys(":profile file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
540 call assert_match('"profile file X1B2C3', @:)
541
542 func Xprof_test()
543 endfunc
544 call feedkeys(":profile func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
545 call assert_equal('"profile func Xprof_test', @:)
546 call feedkeys(":profile func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
547 call assert_equal('"profile func Xprof_test', @:)
548 call feedkeys(":profile func Xprof \<Tab>\<C-B>\"\<CR>", 'tx')
549 call assert_equal('"profile func Xprof ', @:)
550 call feedkeys(":profile func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
551 call assert_equal('"profile func X1B2C3', @:)
552
553 call feedkeys(":profdel \<C-A>\<C-B>\"\<CR>", 'tx')
554 call assert_equal('"profdel file func', @:)
555 call feedkeys(":profdel fu\<Tab>\<C-B>\"\<CR>", 'tx')
556 call assert_equal('"profdel func', @:)
557 call feedkeys(":profdel he\<Tab>\<C-B>\"\<CR>", 'tx')
558 call assert_equal('"profdel he', @:)
559 call feedkeys(":profdel here \<Tab>\<C-B>\"\<CR>", 'tx')
560 call assert_equal('"profdel here ', @:)
561 call feedkeys(":profdel file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
562 call assert_equal('"profdel file test_profile.vim', @:)
563 call feedkeys(":profdel file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
564 call assert_equal('"profdel file X1B2C3', @:)
565 call feedkeys(":profdel func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
566 call assert_equal('"profdel func Xprof_test', @:)
567 call feedkeys(":profdel func Xprof_test \<Tab>\<C-B>\"\<CR>", 'tx')
568 call assert_equal('"profdel func Xprof_test ', @:)
569 call feedkeys(":profdel func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
570 call assert_equal('"profdel func X1B2C3', @:)
571
572 delfunc Xprof_test
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100573endfunc
574
575func Test_profile_errors()
576 call assert_fails("profile func Foo", 'E750:')
577 call assert_fails("profile pause", 'E750:')
578 call assert_fails("profile continue", 'E750:')
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100579 call assert_fails("profile stop", 'E750:')
580 call assert_fails("profile dump", 'E750:')
Bram Moolenaar296b1f22017-01-15 15:22:33 +0100581endfunc
Bram Moolenaarac112f02017-12-05 16:46:28 +0100582
583func Test_profile_truncate_mbyte()
Bram Moolenaar30276f22019-01-24 17:59:39 +0100584 if &enc !=# 'utf-8'
Bram Moolenaarac112f02017-12-05 16:46:28 +0100585 return
586 endif
587
588 let lines = [
589 \ 'scriptencoding utf-8',
590 \ 'func! Foo()',
591 \ ' return [',
592 \ ' \ "' . join(map(range(0x4E00, 0x4E00 + 340), 'nr2char(v:val)'), '') . '",',
593 \ ' \ "' . join(map(range(0x4F00, 0x4F00 + 340), 'nr2char(v:val)'), '') . '",',
594 \ ' \ ]',
595 \ 'endfunc',
596 \ 'call Foo()',
597 \ ]
598
599 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200600 call system(GetVimCommandClean()
601 \ . ' -es --cmd "set enc=utf-8"'
Bram Moolenaarac112f02017-12-05 16:46:28 +0100602 \ . ' -c "profile start Xprofile_file.log"'
603 \ . ' -c "profile file Xprofile_file.vim"'
604 \ . ' -c "so Xprofile_file.vim"'
605 \ . ' -c "qall!"')
606 call assert_equal(0, v:shell_error)
607
608 split Xprofile_file.log
609 if &fenc != ''
610 call assert_equal('utf-8', &fenc)
611 endif
612 /func! Foo()
613 let lnum = line('.')
614 call assert_match('^\s*return \[$', getline(lnum + 1))
615 call assert_match("\u4F52$", getline(lnum + 2))
616 call assert_match("\u5052$", getline(lnum + 3))
617 call assert_match('^\s*\\ \]$', getline(lnum + 4))
618 bwipe!
619
620 call delete('Xprofile_file.vim')
621 call delete('Xprofile_file.log')
622endfunc
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200623
624func Test_profdel_func()
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200625 let lines =<< trim [CODE]
626 profile start Xprofile_file.log
627 func! Foo1()
628 endfunc
629 func! Foo2()
630 endfunc
631 func! Foo3()
632 endfunc
633
634 profile func Foo1
635 profile func Foo2
636 call Foo1()
637 call Foo2()
638
639 profile func Foo3
640 profdel func Foo2
641 profdel func Foo3
642 call Foo1()
643 call Foo2()
644 call Foo3()
645 [CODE]
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200646 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200647 call system(GetVimCommandClean() . ' -es -c "so Xprofile_file.vim" -c q')
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200648 call assert_equal(0, v:shell_error)
649
650 let lines = readfile('Xprofile_file.log')
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200651 call assert_equal(26, len(lines))
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200652
653 " Check that:
654 " - Foo1() is called twice (profdel not invoked)
655 " - Foo2() is called once (profdel invoked after it was called)
656 " - Foo3() is not called (profdel invoked before it was called)
657 call assert_equal('FUNCTION Foo1()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200658 call assert_match('Defined:.*Xprofile_file.vim', lines[1])
659 call assert_equal('Called 2 times', lines[2])
660 call assert_equal('FUNCTION Foo2()', lines[8])
661 call assert_equal('Called 1 time', lines[10])
662 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[16])
663 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[21])
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200664
665 call delete('Xprofile_file.vim')
666 call delete('Xprofile_file.log')
667endfunc
668
669func Test_profdel_star()
670 " Foo() is invoked once before and once after 'profdel *'.
671 " So profiling should report it only once.
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200672 let lines =<< trim [CODE]
673 profile start Xprofile_file.log
674 func! Foo()
675 endfunc
676 profile func Foo
677 call Foo()
678 profdel *
679 call Foo()
680 [CODE]
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200681 call writefile(lines, 'Xprofile_file.vim')
Bram Moolenaar93344c22019-08-14 21:12:05 +0200682 call system(GetVimCommandClean() . ' -es -c "so Xprofile_file.vim" -c q')
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200683 call assert_equal(0, v:shell_error)
684
685 let lines = readfile('Xprofile_file.log')
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200686 call assert_equal(16, len(lines))
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200687
688 call assert_equal('FUNCTION Foo()', lines[0])
Bram Moolenaar4c7b08f2018-09-10 22:03:40 +0200689 call assert_match('Defined:.*Xprofile_file.vim', lines[1])
690 call assert_equal('Called 1 time', lines[2])
691 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[8])
692 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[12])
Bram Moolenaar1fbfe7c2018-06-30 21:18:13 +0200693
694 call delete('Xprofile_file.vim')
695 call delete('Xprofile_file.log')
696endfunc
Bram Moolenaar16358802019-08-30 18:37:26 +0200697
698" When typing the function it won't have a script ID, test that this works.
699func Test_profile_typed_func()
700 CheckScreendump
701
702 let lines =<< trim END
703 profile start XprofileTypedFunc
704 END
705 call writefile(lines, 'XtestProfile')
706 let buf = RunVimInTerminal('-S XtestProfile', #{})
707
708 call term_sendkeys(buf, ":func DoSomething()\<CR>"
709 \ .. "echo 'hello'\<CR>"
710 \ .. "endfunc\<CR>")
711 call term_sendkeys(buf, ":profile func DoSomething\<CR>")
712 call term_sendkeys(buf, ":call DoSomething()\<CR>")
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200713 call TermWait(buf, 100)
Bram Moolenaar16358802019-08-30 18:37:26 +0200714 call StopVimInTerminal(buf)
715 let lines = readfile('XprofileTypedFunc')
716 call assert_equal("FUNCTION DoSomething()", lines[0])
717 call assert_equal("Called 1 time", lines[1])
718
719 " clean up
720 call delete('XprofileTypedFunc')
721 call delete('XtestProfile')
722endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200723
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100724func Test_vim9_profiling()
725 " only tests that compiling and calling functions doesn't crash
726 let lines =<< trim END
727 vim9script
728 def Func()
729 Crash()
730 enddef
731 def Crash()
732 enddef
Bram Moolenaar98989a02021-01-26 12:06:30 +0100733 prof start Xprofile_crash.log
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100734 prof func Func
735 Func()
736 END
Bram Moolenaar98989a02021-01-26 12:06:30 +0100737 call writefile(lines, 'Xprofile_crash.vim')
738 call system(GetVimCommandClean() . ' -es -c "so Xprofile_crash.vim" -c q')
739 call assert_equal(0, v:shell_error)
Bram Moolenaar8c801b32021-03-05 20:58:22 +0100740 call assert_true(readfile('Xprofile_crash.log')->len() > 10)
Bram Moolenaar98989a02021-01-26 12:06:30 +0100741 call delete('Xprofile_crash.vim')
742 call delete('Xprofile_crash.log')
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100743endfunc
744
Bram Moolenaar12d26532021-02-19 19:13:21 +0100745func Test_vim9_nested_call()
746 let lines =<< trim END
747 vim9script
748 var total = 0
749 def One(Ref: func(number))
750 for i in range(3)
751 Ref(i)
752 endfor
753 enddef
754 def Two(nr: number)
755 total += nr
756 enddef
757 prof start Xprofile_nested.log
758 prof func One
759 prof func Two
760 One((nr) => Two(nr))
761 assert_equal(3, total)
762 END
763 call writefile(lines, 'Xprofile_nested.vim')
764 call system(GetVimCommandClean() . ' -es -c "so Xprofile_nested.vim" -c q')
765 call assert_equal(0, v:shell_error)
766
767 let prof_lines = readfile('Xprofile_nested.log')->join('#')
768 call assert_match('FUNCTION <SNR>\d\+_One().*'
769 \ .. '#Called 1 time.*'
770 \ .. '# 1 \s*[0-9.]\+ for i in range(3)'
771 \ .. '# 3 \s*[0-9.]\+ \s*[0-9.]\+ Ref(i)'
772 \ .. '# 3 \s*[0-9.]\+ endfor', prof_lines)
773 call assert_match('FUNCTION <SNR>\d\+_Two().*'
774 \ .. '#Called 3 times.*'
775 \ .. '# 3 \s*[0-9.]\+ total += nr', prof_lines)
Bram Moolenaar4fa11752021-03-03 13:26:02 +0100776 call delete('Xprofile_nested.vim')
777 call delete('Xprofile_nested.log')
Bram Moolenaar12d26532021-02-19 19:13:21 +0100778endfunc
779
Bram Moolenaare5ea3462021-01-25 21:01:48 +0100780
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200781" vim: shiftwidth=2 sts=2 expandtab