blob: 3d37a64562d6dd92f55de336eb01551ab14d152e [file] [log] [blame]
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +02001/* vi:set ts=8 sts=4 sw=4 noet:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * profiler.c: vim script profiler
12 */
13
14#include "vim.h"
15
16#if defined(FEAT_EVAL) || defined(PROTO)
17# if defined(FEAT_PROFILE) || defined(FEAT_RELTIME) || defined(PROTO)
18/*
19 * Store the current time in "tm".
20 */
21 void
22profile_start(proftime_T *tm)
23{
24# ifdef MSWIN
25 QueryPerformanceCounter(tm);
26# else
Ernie Rael076de792023-03-16 21:43:15 +000027 PROF_GET_TIME(tm);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020028# endif
29}
30
31/*
32 * Compute the elapsed time from "tm" till now and store in "tm".
33 */
34 void
35profile_end(proftime_T *tm)
36{
37 proftime_T now;
38
39# ifdef MSWIN
40 QueryPerformanceCounter(&now);
41 tm->QuadPart = now.QuadPart - tm->QuadPart;
42# else
Ernie Rael076de792023-03-16 21:43:15 +000043 PROF_GET_TIME(&now);
44 tm->tv_fsec = now.tv_fsec - tm->tv_fsec;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020045 tm->tv_sec = now.tv_sec - tm->tv_sec;
Ernie Rael076de792023-03-16 21:43:15 +000046 if (tm->tv_fsec < 0)
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020047 {
Ernie Rael076de792023-03-16 21:43:15 +000048 tm->tv_fsec += TV_FSEC_SEC;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020049 --tm->tv_sec;
50 }
51# endif
52}
53
54/*
55 * Subtract the time "tm2" from "tm".
56 */
57 void
58profile_sub(proftime_T *tm, proftime_T *tm2)
59{
60# ifdef MSWIN
61 tm->QuadPart -= tm2->QuadPart;
62# else
Ernie Rael076de792023-03-16 21:43:15 +000063 tm->tv_fsec -= tm2->tv_fsec;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020064 tm->tv_sec -= tm2->tv_sec;
Ernie Rael076de792023-03-16 21:43:15 +000065 if (tm->tv_fsec < 0)
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020066 {
Ernie Rael076de792023-03-16 21:43:15 +000067 tm->tv_fsec += TV_FSEC_SEC;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020068 --tm->tv_sec;
69 }
70# endif
71}
72
73/*
74 * Return a string that represents the time in "tm".
75 * Uses a static buffer!
76 */
77 char *
78profile_msg(proftime_T *tm)
79{
80 static char buf[50];
81
82# ifdef MSWIN
83 LARGE_INTEGER fr;
84
85 QueryPerformanceFrequency(&fr);
86 sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart);
87# else
Ernie Rael076de792023-03-16 21:43:15 +000088 sprintf(buf, PROF_TIME_FORMAT, (long)tm->tv_sec, (long)tm->tv_fsec);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020089# endif
90 return buf;
91}
92
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +020093/*
94 * Return a float that represents the time in "tm".
95 */
96 float_T
97profile_float(proftime_T *tm)
98{
Bram Moolenaar73e28dc2022-09-17 21:08:33 +010099# ifdef MSWIN
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200100 LARGE_INTEGER fr;
101
102 QueryPerformanceFrequency(&fr);
103 return (float_T)tm->QuadPart / (float_T)fr.QuadPart;
Bram Moolenaar73e28dc2022-09-17 21:08:33 +0100104# else
Ernie Rael076de792023-03-16 21:43:15 +0000105 return (float_T)tm->tv_sec + (float_T)tm->tv_fsec / (float_T)TV_FSEC_SEC;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200106# endif
Bram Moolenaar73e28dc2022-09-17 21:08:33 +0100107}
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200108
109/*
110 * Put the time "msec" past now in "tm".
111 */
112 void
113profile_setlimit(long msec, proftime_T *tm)
114{
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200115 if (msec <= 0) // no limit
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200116 profile_zero(tm);
117 else
118 {
119# ifdef MSWIN
120 LARGE_INTEGER fr;
121
122 QueryPerformanceCounter(tm);
123 QueryPerformanceFrequency(&fr);
124 tm->QuadPart += (LONGLONG)((double)msec / 1000.0 * (double)fr.QuadPart);
125# else
Ernie Rael076de792023-03-16 21:43:15 +0000126 long fsec;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200127
Ernie Rael076de792023-03-16 21:43:15 +0000128 PROF_GET_TIME(tm);
129 fsec = (long)tm->tv_fsec + (long)msec * (TV_FSEC_SEC / 1000);
130 tm->tv_fsec = fsec % (long)TV_FSEC_SEC;
131 tm->tv_sec += fsec / (long)TV_FSEC_SEC;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200132# endif
133 }
134}
135
136/*
137 * Return TRUE if the current time is past "tm".
138 */
139 int
140profile_passed_limit(proftime_T *tm)
141{
142 proftime_T now;
143
144# ifdef MSWIN
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200145 if (tm->QuadPart == 0) // timer was not set
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200146 return FALSE;
147 QueryPerformanceCounter(&now);
148 return (now.QuadPart > tm->QuadPart);
149# else
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200150 if (tm->tv_sec == 0) // timer was not set
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200151 return FALSE;
Ernie Rael076de792023-03-16 21:43:15 +0000152 PROF_GET_TIME(&now);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200153 return (now.tv_sec > tm->tv_sec
Ernie Rael076de792023-03-16 21:43:15 +0000154 || (now.tv_sec == tm->tv_sec && now.tv_fsec > tm->tv_fsec));
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200155# endif
156}
157
158/*
159 * Set the time in "tm" to zero.
160 */
161 void
162profile_zero(proftime_T *tm)
163{
164# ifdef MSWIN
165 tm->QuadPart = 0;
166# else
Ernie Rael076de792023-03-16 21:43:15 +0000167 tm->tv_fsec = 0;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200168 tm->tv_sec = 0;
169# endif
170}
171
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200172# endif // FEAT_PROFILE || FEAT_RELTIME
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200173
Bram Moolenaar73e28dc2022-09-17 21:08:33 +0100174#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_PROFILE)
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200175# if defined(HAVE_MATH_H)
176# include <math.h>
177# endif
178
179/*
180 * Divide the time "tm" by "count" and store in "tm2".
181 */
182 void
183profile_divide(proftime_T *tm, int count, proftime_T *tm2)
184{
185 if (count == 0)
186 profile_zero(tm2);
187 else
188 {
189# ifdef MSWIN
190 tm2->QuadPart = tm->QuadPart / count;
191# else
Ernie Rael076de792023-03-16 21:43:15 +0000192 double fsec = (tm->tv_sec * (float_T)TV_FSEC_SEC + tm->tv_fsec)
193 / count;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200194
Ernie Rael076de792023-03-16 21:43:15 +0000195 tm2->tv_sec = floor(fsec / (float_T)TV_FSEC_SEC);
196 tm2->tv_fsec = vim_round(fsec - (tm2->tv_sec * (float_T)TV_FSEC_SEC));
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200197# endif
198 }
199}
200#endif
201
202# if defined(FEAT_PROFILE) || defined(PROTO)
203/*
204 * Functions for profiling.
205 */
206static proftime_T prof_wait_time;
207
208/*
209 * Add the time "tm2" to "tm".
210 */
211 void
212profile_add(proftime_T *tm, proftime_T *tm2)
213{
214# ifdef MSWIN
215 tm->QuadPart += tm2->QuadPart;
216# else
Ernie Rael076de792023-03-16 21:43:15 +0000217 tm->tv_fsec += tm2->tv_fsec;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200218 tm->tv_sec += tm2->tv_sec;
Ernie Rael076de792023-03-16 21:43:15 +0000219 if (tm->tv_fsec >= TV_FSEC_SEC)
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200220 {
Ernie Rael076de792023-03-16 21:43:15 +0000221 tm->tv_fsec -= TV_FSEC_SEC;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200222 ++tm->tv_sec;
223 }
224# endif
225}
226
227/*
228 * Add the "self" time from the total time and the children's time.
229 */
230 void
231profile_self(proftime_T *self, proftime_T *total, proftime_T *children)
232{
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200233 // Check that the result won't be negative. Can happen with recursive
234 // calls.
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200235#ifdef MSWIN
236 if (total->QuadPart <= children->QuadPart)
237 return;
238#else
239 if (total->tv_sec < children->tv_sec
240 || (total->tv_sec == children->tv_sec
Ernie Rael076de792023-03-16 21:43:15 +0000241 && total->tv_fsec <= children->tv_fsec))
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200242 return;
243#endif
244 profile_add(self, total);
245 profile_sub(self, children);
246}
247
248/*
249 * Get the current waittime.
250 */
Bram Moolenaar5843f5f2019-08-20 20:13:45 +0200251 static void
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200252profile_get_wait(proftime_T *tm)
253{
254 *tm = prof_wait_time;
255}
256
257/*
258 * Subtract the passed waittime since "tm" from "tma".
259 */
260 void
261profile_sub_wait(proftime_T *tm, proftime_T *tma)
262{
263 proftime_T tm3 = prof_wait_time;
264
265 profile_sub(&tm3, tm);
266 profile_sub(tma, &tm3);
267}
268
269/*
270 * Return TRUE if "tm1" and "tm2" are equal.
271 */
Bram Moolenaar5843f5f2019-08-20 20:13:45 +0200272 static int
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200273profile_equal(proftime_T *tm1, proftime_T *tm2)
274{
275# ifdef MSWIN
276 return (tm1->QuadPart == tm2->QuadPart);
277# else
Ernie Rael076de792023-03-16 21:43:15 +0000278 return (tm1->tv_fsec == tm2->tv_fsec && tm1->tv_sec == tm2->tv_sec);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200279# endif
280}
281
282/*
283 * Return <0, 0 or >0 if "tm1" < "tm2", "tm1" == "tm2" or "tm1" > "tm2"
284 */
285 int
286profile_cmp(const proftime_T *tm1, const proftime_T *tm2)
287{
288# ifdef MSWIN
289 return (int)(tm2->QuadPart - tm1->QuadPart);
290# else
291 if (tm1->tv_sec == tm2->tv_sec)
Ernie Rael076de792023-03-16 21:43:15 +0000292 return tm2->tv_fsec - tm1->tv_fsec;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200293 return tm2->tv_sec - tm1->tv_sec;
294# endif
295}
296
297static char_u *profile_fname = NULL;
298static proftime_T pause_time;
299
300/*
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100301 * Reset all profiling information.
302 */
303 static void
304profile_reset(void)
305{
306 int id;
307 int todo;
308 hashtab_T *functbl;
309 hashitem_T *hi;
310
311 // Reset sourced files.
312 for (id = 1; id <= script_items.ga_len; id++)
313 {
314 scriptitem_T *si = SCRIPT_ITEM(id);
315 if (si->sn_prof_on)
316 {
317 si->sn_prof_on = FALSE;
318 si->sn_pr_force = FALSE;
319 profile_zero(&si->sn_pr_child);
320 si->sn_pr_nest = 0;
321 si->sn_pr_count = 0;
322 profile_zero(&si->sn_pr_total);
323 profile_zero(&si->sn_pr_self);
324 profile_zero(&si->sn_pr_start);
325 profile_zero(&si->sn_pr_children);
326 ga_clear(&si->sn_prl_ga);
327 profile_zero(&si->sn_prl_start);
328 profile_zero(&si->sn_prl_children);
329 profile_zero(&si->sn_prl_wait);
330 si->sn_prl_idx = -1;
331 si->sn_prl_execed = 0;
332 }
333 }
334
335 // Reset functions.
336 functbl = func_tbl_get();
337 todo = (int)functbl->ht_used;
338
Yegappan Lakshmanan14113fd2023-03-07 17:13:51 +0000339 FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100340 {
341 ufunc_T *fp;
342 int i;
343
344 if (HASHITEM_EMPTY(hi))
345 continue;
346
347 todo--;
348 fp = HI2UF(hi);
349 if (fp->uf_prof_initialized)
350 {
351 fp->uf_profiling = 0;
352 fp->uf_prof_initialized = FALSE;
353 fp->uf_tm_count = 0;
354 profile_zero(&fp->uf_tm_total);
355 profile_zero(&fp->uf_tm_self);
356 profile_zero(&fp->uf_tm_children);
357
358 for (i = 0; i < fp->uf_lines.ga_len; i++)
359 {
360 fp->uf_tml_count[i] = 0;
361 profile_zero(&fp->uf_tml_total[i]);
362 profile_zero(&fp->uf_tml_self[i]);
363 }
364
365 profile_zero(&fp->uf_tml_start);
366 profile_zero(&fp->uf_tml_children);
367 profile_zero(&fp->uf_tml_wait);
368 fp->uf_tml_idx = -1;
369 fp->uf_tml_execed = 0;
370 }
371 }
372
373 VIM_CLEAR(profile_fname);
374}
375
376/*
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200377 * ":profile cmd args"
378 */
379 void
380ex_profile(exarg_T *eap)
381{
382 char_u *e;
383 int len;
384
385 e = skiptowhite(eap->arg);
386 len = (int)(e - eap->arg);
387 e = skipwhite(e);
388
389 if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL)
390 {
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100391 VIM_CLEAR(profile_fname);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200392 profile_fname = expand_env_save_opt(e, TRUE);
393 do_profiling = PROF_YES;
394 profile_zero(&prof_wait_time);
395 set_vim_var_nr(VV_PROFILING, 1L);
396 }
397 else if (do_profiling == PROF_NONE)
Bram Moolenaar677658a2022-01-05 16:09:06 +0000398 emsg(_(e_first_use_profile_start_fname));
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100399 else if (STRCMP(eap->arg, "stop") == 0)
400 {
401 profile_dump();
402 do_profiling = PROF_NONE;
403 set_vim_var_nr(VV_PROFILING, 0L);
404 profile_reset();
405 }
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200406 else if (STRCMP(eap->arg, "pause") == 0)
407 {
408 if (do_profiling == PROF_YES)
409 profile_start(&pause_time);
410 do_profiling = PROF_PAUSED;
411 }
412 else if (STRCMP(eap->arg, "continue") == 0)
413 {
414 if (do_profiling == PROF_PAUSED)
415 {
416 profile_end(&pause_time);
417 profile_add(&prof_wait_time, &pause_time);
418 }
419 do_profiling = PROF_YES;
420 }
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100421 else if (STRCMP(eap->arg, "dump") == 0)
422 profile_dump();
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200423 else
424 {
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200425 // The rest is similar to ":breakadd".
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200426 ex_breakadd(eap);
427 }
428}
429
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200430// Command line expansion for :profile.
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200431static enum
432{
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200433 PEXP_SUBCMD, // expand :profile sub-commands
434 PEXP_FUNC // expand :profile func {funcname}
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200435} pexpand_what;
436
437static char *pexpand_cmds[] = {
438 "start",
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100439 "stop",
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200440 "pause",
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200441 "continue",
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200442 "func",
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200443 "file",
Yegappan Lakshmanan18ee0f62022-04-08 13:23:19 +0100444 "dump",
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200445 NULL
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200446};
447
448/*
449 * Function given to ExpandGeneric() to obtain the profile command
450 * specific expansion.
451 */
452 char_u *
453get_profile_name(expand_T *xp UNUSED, int idx)
454{
455 switch (pexpand_what)
456 {
457 case PEXP_SUBCMD:
458 return (char_u *)pexpand_cmds[idx];
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200459 default:
460 return NULL;
461 }
462}
463
464/*
465 * Handle command line completion for :profile command.
466 */
467 void
468set_context_in_profile_cmd(expand_T *xp, char_u *arg)
469{
470 char_u *end_subcmd;
471
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200472 // Default: expand subcommands.
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200473 xp->xp_context = EXPAND_PROFILE;
474 pexpand_what = PEXP_SUBCMD;
475 xp->xp_pattern = arg;
476
477 end_subcmd = skiptowhite(arg);
478 if (*end_subcmd == NUL)
479 return;
480
Yegappan Lakshmanan1fdf84e2022-03-15 10:53:09 +0000481 if ((end_subcmd - arg == 5 && STRNCMP(arg, "start", 5) == 0)
482 || (end_subcmd - arg == 4 && STRNCMP(arg, "file", 4) == 0))
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200483 {
484 xp->xp_context = EXPAND_FILES;
485 xp->xp_pattern = skipwhite(end_subcmd);
486 return;
487 }
Yegappan Lakshmanan1fdf84e2022-03-15 10:53:09 +0000488 else if (end_subcmd - arg == 4 && STRNCMP(arg, "func", 4) == 0)
489 {
490 xp->xp_context = EXPAND_USER_FUNC;
491 xp->xp_pattern = skipwhite(end_subcmd);
492 return;
493 }
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200494
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200495 xp->xp_context = EXPAND_NOTHING;
496}
497
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200498static proftime_T inchar_time;
499
500/*
501 * Called when starting to wait for the user to type a character.
502 */
503 void
504prof_inchar_enter(void)
505{
506 profile_start(&inchar_time);
507}
508
509/*
510 * Called when finished waiting for the user to type a character.
511 */
512 void
513prof_inchar_exit(void)
514{
515 profile_end(&inchar_time);
516 profile_add(&prof_wait_time, &inchar_time);
517}
518
519
520/*
521 * Return TRUE when a function defined in the current script should be
522 * profiled.
523 */
524 int
525prof_def_func(void)
526{
527 if (current_sctx.sc_sid > 0)
Bram Moolenaar21b9e972020-01-26 19:26:46 +0100528 return SCRIPT_ITEM(current_sctx.sc_sid)->sn_pr_force;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200529 return FALSE;
530}
531
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200532/*
533 * Print the count and times for one function or function line.
534 */
535 static void
536prof_func_line(
537 FILE *fd,
538 int count,
539 proftime_T *total,
540 proftime_T *self,
541 int prefer_self) // when equal print only self time
542{
543 if (count > 0)
544 {
545 fprintf(fd, "%5d ", count);
546 if (prefer_self && profile_equal(total, self))
Ernie Rael076de792023-03-16 21:43:15 +0000547 fprintf(fd, PROF_TIME_BLANK);
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200548 else
549 fprintf(fd, "%s ", profile_msg(total));
550 if (!prefer_self && profile_equal(total, self))
Ernie Rael076de792023-03-16 21:43:15 +0000551 fprintf(fd, PROF_TIME_BLANK);
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200552 else
553 fprintf(fd, "%s ", profile_msg(self));
554 }
555 else
Ernie Rael076de792023-03-16 21:43:15 +0000556 fprintf(fd, " %s%s", PROF_TIME_BLANK, PROF_TIME_BLANK);
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200557}
558
559 static void
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200560prof_sort_list(
561 FILE *fd,
562 ufunc_T **sorttab,
563 int st_len,
564 char *title,
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200565 int prefer_self) // when equal print only self time
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200566{
567 int i;
568 ufunc_T *fp;
569
570 fprintf(fd, "FUNCTIONS SORTED ON %s TIME\n", title);
Ernie Rael076de792023-03-16 21:43:15 +0000571 fprintf(fd, "%s function\n", PROF_TOTALS_HEADER);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200572 for (i = 0; i < 20 && i < st_len; ++i)
573 {
574 fp = sorttab[i];
575 prof_func_line(fd, fp->uf_tm_count, &fp->uf_tm_total, &fp->uf_tm_self,
576 prefer_self);
577 if (fp->uf_name[0] == K_SPECIAL)
578 fprintf(fd, " <SNR>%s()\n", fp->uf_name + 3);
579 else
580 fprintf(fd, " %s()\n", fp->uf_name);
581 }
582 fprintf(fd, "\n");
583}
584
585/*
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200586 * Compare function for total time sorting.
587 */
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200588 static int
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200589prof_total_cmp(const void *s1, const void *s2)
590{
591 ufunc_T *p1, *p2;
592
593 p1 = *(ufunc_T **)s1;
594 p2 = *(ufunc_T **)s2;
595 return profile_cmp(&p1->uf_tm_total, &p2->uf_tm_total);
596}
597
598/*
599 * Compare function for self time sorting.
600 */
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200601 static int
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200602prof_self_cmp(const void *s1, const void *s2)
603{
604 ufunc_T *p1, *p2;
605
606 p1 = *(ufunc_T **)s1;
607 p2 = *(ufunc_T **)s2;
608 return profile_cmp(&p1->uf_tm_self, &p2->uf_tm_self);
609}
610
611/*
612 * Start profiling function "fp".
613 */
614 void
615func_do_profile(ufunc_T *fp)
616{
617 int len = fp->uf_lines.ga_len;
618
619 if (!fp->uf_prof_initialized)
620 {
621 if (len == 0)
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200622 len = 1; // avoid getting error for allocating zero bytes
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200623 fp->uf_tm_count = 0;
624 profile_zero(&fp->uf_tm_self);
625 profile_zero(&fp->uf_tm_total);
626 if (fp->uf_tml_count == NULL)
627 fp->uf_tml_count = ALLOC_CLEAR_MULT(int, len);
628 if (fp->uf_tml_total == NULL)
629 fp->uf_tml_total = ALLOC_CLEAR_MULT(proftime_T, len);
630 if (fp->uf_tml_self == NULL)
631 fp->uf_tml_self = ALLOC_CLEAR_MULT(proftime_T, len);
632 fp->uf_tml_idx = -1;
633 if (fp->uf_tml_count == NULL || fp->uf_tml_total == NULL
634 || fp->uf_tml_self == NULL)
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200635 return; // out of memory
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200636 fp->uf_prof_initialized = TRUE;
637 }
638
639 fp->uf_profiling = TRUE;
640}
641
642/*
Yegappan Lakshmanan8ee52af2021-08-09 19:59:06 +0200643 * Save time when starting to invoke another script or function.
644 */
645 static void
646script_prof_save(
647 proftime_T *tm) // place to store wait time
648{
649 scriptitem_T *si;
650
651 if (SCRIPT_ID_VALID(current_sctx.sc_sid))
652 {
653 si = SCRIPT_ITEM(current_sctx.sc_sid);
654 if (si->sn_prof_on && si->sn_pr_nest++ == 0)
655 profile_start(&si->sn_pr_child);
656 }
657 profile_get_wait(tm);
658}
659
660/*
Bram Moolenaarb2049902021-01-24 12:53:53 +0100661 * When calling a function: may initialize for profiling.
662 */
663 void
Bram Moolenaar12d26532021-02-19 19:13:21 +0100664profile_may_start_func(profinfo_T *info, ufunc_T *fp, ufunc_T *caller)
Bram Moolenaarb2049902021-01-24 12:53:53 +0100665{
Bram Moolenaar12d26532021-02-19 19:13:21 +0100666 if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL))
Bram Moolenaarb2049902021-01-24 12:53:53 +0100667 {
Bram Moolenaar12d26532021-02-19 19:13:21 +0100668 info->pi_started_profiling = TRUE;
669 func_do_profile(fp);
Bram Moolenaarb2049902021-01-24 12:53:53 +0100670 }
Bram Moolenaar12d26532021-02-19 19:13:21 +0100671 if (fp->uf_profiling || (caller != NULL && caller->uf_profiling))
672 {
673 ++fp->uf_tm_count;
674 profile_start(&info->pi_call_start);
675 profile_zero(&fp->uf_tm_children);
676 }
677 script_prof_save(&info->pi_wait_start);
Bram Moolenaarb2049902021-01-24 12:53:53 +0100678}
679
680/*
681 * After calling a function: may handle profiling. profile_may_start_func()
682 * must have been called previously.
683 */
684 void
Bram Moolenaar12d26532021-02-19 19:13:21 +0100685profile_may_end_func(profinfo_T *info, ufunc_T *fp, ufunc_T *caller)
Bram Moolenaarb2049902021-01-24 12:53:53 +0100686{
687 profile_end(&info->pi_call_start);
688 profile_sub_wait(&info->pi_wait_start, &info->pi_call_start);
689 profile_add(&fp->uf_tm_total, &info->pi_call_start);
690 profile_self(&fp->uf_tm_self, &info->pi_call_start, &fp->uf_tm_children);
Bram Moolenaar12d26532021-02-19 19:13:21 +0100691 if (caller != NULL && caller->uf_profiling)
Bram Moolenaarb2049902021-01-24 12:53:53 +0100692 {
Bram Moolenaar12d26532021-02-19 19:13:21 +0100693 profile_add(&caller->uf_tm_children, &info->pi_call_start);
694 profile_add(&caller->uf_tml_children, &info->pi_call_start);
Bram Moolenaarb2049902021-01-24 12:53:53 +0100695 }
696 if (info->pi_started_profiling)
697 // make a ":profdel func" stop profiling the function
698 fp->uf_profiling = FALSE;
699}
700
701/*
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200702 * Prepare profiling for entering a child or something else that is not
703 * counted for the script/function itself.
704 * Should always be called in pair with prof_child_exit().
705 */
706 void
707prof_child_enter(
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200708 proftime_T *tm) // place to store waittime
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200709{
710 funccall_T *fc = get_current_funccal();
711
Bram Moolenaarca16c602022-09-06 18:57:08 +0100712 if (fc != NULL && fc->fc_func->uf_profiling)
713 profile_start(&fc->fc_prof_child);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200714 script_prof_save(tm);
715}
716
717/*
718 * Take care of time spent in a child.
719 * Should always be called after prof_child_enter().
720 */
721 void
722prof_child_exit(
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200723 proftime_T *tm) // where waittime was stored
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200724{
725 funccall_T *fc = get_current_funccal();
726
Bram Moolenaarca16c602022-09-06 18:57:08 +0100727 if (fc != NULL && fc->fc_func->uf_profiling)
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200728 {
Bram Moolenaarca16c602022-09-06 18:57:08 +0100729 profile_end(&fc->fc_prof_child);
730 profile_sub_wait(tm, &fc->fc_prof_child); // don't count waiting time
731 profile_add(&fc->fc_func->uf_tm_children, &fc->fc_prof_child);
732 profile_add(&fc->fc_func->uf_tml_children, &fc->fc_prof_child);
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200733 }
734 script_prof_restore(tm);
735}
736
737/*
738 * Called when starting to read a function line.
739 * "sourcing_lnum" must be correct!
740 * When skipping lines it may not actually be executed, but we won't find out
741 * until later and we need to store the time now.
742 */
743 void
Bram Moolenaarb2049902021-01-24 12:53:53 +0100744func_line_start(void *cookie, long lnum)
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200745{
746 funccall_T *fcp = (funccall_T *)cookie;
Bram Moolenaarca16c602022-09-06 18:57:08 +0100747 ufunc_T *fp = fcp->fc_func;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200748
Bram Moolenaarb2049902021-01-24 12:53:53 +0100749 if (fp->uf_profiling && lnum >= 1 && lnum <= fp->uf_lines.ga_len)
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200750 {
Bram Moolenaarb2049902021-01-24 12:53:53 +0100751 fp->uf_tml_idx = lnum - 1;
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200752 // Skip continuation lines.
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200753 while (fp->uf_tml_idx > 0 && FUNCLINE(fp, fp->uf_tml_idx) == NULL)
754 --fp->uf_tml_idx;
755 fp->uf_tml_execed = FALSE;
756 profile_start(&fp->uf_tml_start);
757 profile_zero(&fp->uf_tml_children);
758 profile_get_wait(&fp->uf_tml_wait);
759 }
760}
761
762/*
763 * Called when actually executing a function line.
764 */
765 void
766func_line_exec(void *cookie)
767{
768 funccall_T *fcp = (funccall_T *)cookie;
Bram Moolenaarca16c602022-09-06 18:57:08 +0100769 ufunc_T *fp = fcp->fc_func;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200770
771 if (fp->uf_profiling && fp->uf_tml_idx >= 0)
772 fp->uf_tml_execed = TRUE;
773}
774
775/*
776 * Called when done with a function line.
777 */
778 void
779func_line_end(void *cookie)
780{
781 funccall_T *fcp = (funccall_T *)cookie;
Bram Moolenaarca16c602022-09-06 18:57:08 +0100782 ufunc_T *fp = fcp->fc_func;
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +0200783
784 if (fp->uf_profiling && fp->uf_tml_idx >= 0)
785 {
786 if (fp->uf_tml_execed)
787 {
788 ++fp->uf_tml_count[fp->uf_tml_idx];
789 profile_end(&fp->uf_tml_start);
790 profile_sub_wait(&fp->uf_tml_wait, &fp->uf_tml_start);
791 profile_add(&fp->uf_tml_total[fp->uf_tml_idx], &fp->uf_tml_start);
792 profile_self(&fp->uf_tml_self[fp->uf_tml_idx], &fp->uf_tml_start,
793 &fp->uf_tml_children);
794 }
795 fp->uf_tml_idx = -1;
796 }
797}
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200798
799/*
800 * Dump the profiling results for all functions in file "fd".
801 */
802 static void
803func_dump_profile(FILE *fd)
804{
805 hashtab_T *functbl;
806 hashitem_T *hi;
807 int todo;
808 ufunc_T *fp;
809 int i;
810 ufunc_T **sorttab;
811 int st_len = 0;
812 char_u *p;
813
814 functbl = func_tbl_get();
815 todo = (int)functbl->ht_used;
816 if (todo == 0)
817 return; // nothing to dump
818
819 sorttab = ALLOC_MULT(ufunc_T *, todo);
820
Yegappan Lakshmanan14113fd2023-03-07 17:13:51 +0000821 FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200822 {
823 if (!HASHITEM_EMPTY(hi))
824 {
825 --todo;
826 fp = HI2UF(hi);
827 if (fp->uf_prof_initialized)
828 {
829 if (sorttab != NULL)
830 sorttab[st_len++] = fp;
831
832 if (fp->uf_name[0] == K_SPECIAL)
833 fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3);
834 else
835 fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
Bram Moolenaar16358802019-08-30 18:37:26 +0200836 if (fp->uf_script_ctx.sc_sid > 0)
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200837 {
Bram Moolenaar16358802019-08-30 18:37:26 +0200838 p = home_replace_save(NULL,
839 get_scriptname(fp->uf_script_ctx.sc_sid));
840 if (p != NULL)
841 {
Bram Moolenaar181d4f52019-09-18 22:04:56 +0200842 fprintf(fd, " Defined: %s:%ld\n",
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200843 p, (long)fp->uf_script_ctx.sc_lnum);
Bram Moolenaar16358802019-08-30 18:37:26 +0200844 vim_free(p);
845 }
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200846 }
847 if (fp->uf_tm_count == 1)
848 fprintf(fd, "Called 1 time\n");
849 else
850 fprintf(fd, "Called %d times\n", fp->uf_tm_count);
851 fprintf(fd, "Total time: %s\n", profile_msg(&fp->uf_tm_total));
852 fprintf(fd, " Self time: %s\n", profile_msg(&fp->uf_tm_self));
853 fprintf(fd, "\n");
Ernie Rael076de792023-03-16 21:43:15 +0000854 fprintf(fd, "%s\n", PROF_TOTALS_HEADER);
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200855
856 for (i = 0; i < fp->uf_lines.ga_len; ++i)
857 {
858 if (FUNCLINE(fp, i) == NULL)
859 continue;
860 prof_func_line(fd, fp->uf_tml_count[i],
861 &fp->uf_tml_total[i], &fp->uf_tml_self[i], TRUE);
862 fprintf(fd, "%s\n", FUNCLINE(fp, i));
863 }
864 fprintf(fd, "\n");
865 }
866 }
867 }
868
869 if (sorttab != NULL && st_len > 0)
870 {
871 qsort((void *)sorttab, (size_t)st_len, sizeof(ufunc_T *),
872 prof_total_cmp);
873 prof_sort_list(fd, sorttab, st_len, "TOTAL", FALSE);
874 qsort((void *)sorttab, (size_t)st_len, sizeof(ufunc_T *),
875 prof_self_cmp);
876 prof_sort_list(fd, sorttab, st_len, "SELF", TRUE);
877 }
878
879 vim_free(sorttab);
880}
881
882/*
883 * Start profiling script "fp".
884 */
885 void
886script_do_profile(scriptitem_T *si)
887{
888 si->sn_pr_count = 0;
889 profile_zero(&si->sn_pr_total);
890 profile_zero(&si->sn_pr_self);
891
892 ga_init2(&si->sn_prl_ga, sizeof(sn_prl_T), 100);
893 si->sn_prl_idx = -1;
894 si->sn_prof_on = TRUE;
895 si->sn_pr_nest = 0;
896}
897
898/*
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200899 * Count time spent in children after invoking another script or function.
900 */
901 void
902script_prof_restore(proftime_T *tm)
903{
904 scriptitem_T *si;
905
Yegappan Lakshmananf97a2952023-01-18 18:17:48 +0000906 if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
907 return;
908
909 si = SCRIPT_ITEM(current_sctx.sc_sid);
910 if (si->sn_prof_on && --si->sn_pr_nest == 0)
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200911 {
Yegappan Lakshmananf97a2952023-01-18 18:17:48 +0000912 profile_end(&si->sn_pr_child);
913 profile_sub_wait(tm, &si->sn_pr_child); // don't count wait time
914 profile_add(&si->sn_pr_children, &si->sn_pr_child);
915 profile_add(&si->sn_prl_children, &si->sn_pr_child);
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200916 }
917}
918
919/*
920 * Dump the profiling results for all scripts in file "fd".
921 */
922 static void
923script_dump_profile(FILE *fd)
924{
925 int id;
926 scriptitem_T *si;
927 int i;
928 FILE *sfd;
929 sn_prl_T *pp;
930
931 for (id = 1; id <= script_items.ga_len; ++id)
932 {
Bram Moolenaar21b9e972020-01-26 19:26:46 +0100933 si = SCRIPT_ITEM(id);
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200934 if (si->sn_prof_on)
935 {
936 fprintf(fd, "SCRIPT %s\n", si->sn_name);
937 if (si->sn_pr_count == 1)
938 fprintf(fd, "Sourced 1 time\n");
939 else
940 fprintf(fd, "Sourced %d times\n", si->sn_pr_count);
941 fprintf(fd, "Total time: %s\n", profile_msg(&si->sn_pr_total));
942 fprintf(fd, " Self time: %s\n", profile_msg(&si->sn_pr_self));
943 fprintf(fd, "\n");
Ernie Rael076de792023-03-16 21:43:15 +0000944 fprintf(fd, "%s\n", PROF_TOTALS_HEADER);
Bram Moolenaar660a10a2019-07-14 15:48:38 +0200945
946 sfd = mch_fopen((char *)si->sn_name, "r");
947 if (sfd == NULL)
948 fprintf(fd, "Cannot open file!\n");
949 else
950 {
951 // Keep going till the end of file, so that trailing
952 // continuation lines are listed.
953 for (i = 0; ; ++i)
954 {
955 if (vim_fgets(IObuff, IOSIZE, sfd))
956 break;
957 // When a line has been truncated, append NL, taking care
958 // of multi-byte characters .
959 if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL)
960 {
961 int n = IOSIZE - 2;
962
963 if (enc_utf8)
964 {
965 // Move to the first byte of this char.
966 // utf_head_off() doesn't work, because it checks
967 // for a truncated character.
968 while (n > 0 && (IObuff[n] & 0xc0) == 0x80)
969 --n;
970 }
971 else if (has_mbyte)
972 n -= mb_head_off(IObuff, IObuff + n);
973 IObuff[n] = NL;
974 IObuff[n + 1] = NUL;
975 }
976 if (i < si->sn_prl_ga.ga_len
977 && (pp = &PRL_ITEM(si, i))->snp_count > 0)
978 {
979 fprintf(fd, "%5d ", pp->snp_count);
980 if (profile_equal(&pp->sn_prl_total, &pp->sn_prl_self))
981 fprintf(fd, " ");
982 else
983 fprintf(fd, "%s ", profile_msg(&pp->sn_prl_total));
984 fprintf(fd, "%s ", profile_msg(&pp->sn_prl_self));
985 }
986 else
987 fprintf(fd, " ");
988 fprintf(fd, "%s", IObuff);
989 }
990 fclose(sfd);
991 }
992 fprintf(fd, "\n");
993 }
994 }
995}
996
997/*
998 * Dump the profiling info.
999 */
1000 void
1001profile_dump(void)
1002{
1003 FILE *fd;
1004
Yegappan Lakshmananf97a2952023-01-18 18:17:48 +00001005 if (profile_fname == NULL)
1006 return;
1007
1008 fd = mch_fopen((char *)profile_fname, "w");
1009 if (fd == NULL)
1010 semsg(_(e_cant_open_file_str), profile_fname);
1011 else
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001012 {
Yegappan Lakshmananf97a2952023-01-18 18:17:48 +00001013 script_dump_profile(fd);
1014 func_dump_profile(fd);
1015 fclose(fd);
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001016 }
1017}
1018
1019/*
1020 * Called when starting to read a script line.
1021 * "sourcing_lnum" must be correct!
1022 * When skipping lines it may not actually be executed, but we won't find out
1023 * until later and we need to store the time now.
1024 */
1025 void
1026script_line_start(void)
1027{
1028 scriptitem_T *si;
1029 sn_prl_T *pp;
1030
Bram Moolenaare3d46852020-08-29 13:39:17 +02001031 if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001032 return;
Bram Moolenaar21b9e972020-01-26 19:26:46 +01001033 si = SCRIPT_ITEM(current_sctx.sc_sid);
Bram Moolenaar1a47ae32019-12-29 23:04:25 +01001034 if (si->sn_prof_on && SOURCING_LNUM >= 1)
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001035 {
1036 // Grow the array before starting the timer, so that the time spent
1037 // here isn't counted.
1038 (void)ga_grow(&si->sn_prl_ga,
Bram Moolenaar1a47ae32019-12-29 23:04:25 +01001039 (int)(SOURCING_LNUM - si->sn_prl_ga.ga_len));
1040 si->sn_prl_idx = SOURCING_LNUM - 1;
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001041 while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
1042 && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen)
1043 {
1044 // Zero counters for a line that was not used before.
1045 pp = &PRL_ITEM(si, si->sn_prl_ga.ga_len);
1046 pp->snp_count = 0;
1047 profile_zero(&pp->sn_prl_total);
1048 profile_zero(&pp->sn_prl_self);
1049 ++si->sn_prl_ga.ga_len;
1050 }
1051 si->sn_prl_execed = FALSE;
1052 profile_start(&si->sn_prl_start);
1053 profile_zero(&si->sn_prl_children);
1054 profile_get_wait(&si->sn_prl_wait);
1055 }
1056}
1057
1058/*
1059 * Called when actually executing a function line.
1060 */
1061 void
1062script_line_exec(void)
1063{
1064 scriptitem_T *si;
1065
Bram Moolenaare3d46852020-08-29 13:39:17 +02001066 if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001067 return;
Bram Moolenaar21b9e972020-01-26 19:26:46 +01001068 si = SCRIPT_ITEM(current_sctx.sc_sid);
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001069 if (si->sn_prof_on && si->sn_prl_idx >= 0)
1070 si->sn_prl_execed = TRUE;
1071}
1072
1073/*
1074 * Called when done with a script line.
1075 */
1076 void
1077script_line_end(void)
1078{
1079 scriptitem_T *si;
1080 sn_prl_T *pp;
1081
Bram Moolenaare3d46852020-08-29 13:39:17 +02001082 if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001083 return;
Bram Moolenaar21b9e972020-01-26 19:26:46 +01001084 si = SCRIPT_ITEM(current_sctx.sc_sid);
Bram Moolenaar660a10a2019-07-14 15:48:38 +02001085 if (si->sn_prof_on && si->sn_prl_idx >= 0
1086 && si->sn_prl_idx < si->sn_prl_ga.ga_len)
1087 {
1088 if (si->sn_prl_execed)
1089 {
1090 pp = &PRL_ITEM(si, si->sn_prl_idx);
1091 ++pp->snp_count;
1092 profile_end(&si->sn_prl_start);
1093 profile_sub_wait(&si->sn_prl_wait, &si->sn_prl_start);
1094 profile_add(&pp->sn_prl_total, &si->sn_prl_start);
1095 profile_self(&pp->sn_prl_self, &si->sn_prl_start,
1096 &si->sn_prl_children);
1097 }
1098 si->sn_prl_idx = -1;
1099 }
1100}
1101# endif // FEAT_PROFILE
Bram Moolenaarfa55cfc2019-07-13 22:59:32 +02001102
1103#endif