comparison src/profiler.c @ 23976:03819ebd3e6d v8.2.2530

patch 8.2.2530: Vim9: not enough testing for profiling Commit: https://github.com/vim/vim/commit/12d265315fac9e4f3436c38a87f6d9a23b9e7e2b Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 19 19:13:21 2021 +0100 patch 8.2.2530: Vim9: not enough testing for profiling Problem: Vim9: not enough testing for profiling. Solution: Add a test with nested functions and a lambda. Fix profiling for calling a compiled function.
author Bram Moolenaar <Bram@vim.org>
date Fri, 19 Feb 2021 19:15:03 +0100
parents e3720756acdc
children 0082503ff2ff
comparison
equal deleted inserted replaced
23975:a1b074b83f39 23976:03819ebd3e6d
556 556
557 /* 557 /*
558 * When calling a function: may initialize for profiling. 558 * When calling a function: may initialize for profiling.
559 */ 559 */
560 void 560 void
561 profile_may_start_func(profinfo_T *info, ufunc_T *fp, funccall_T *fc) 561 profile_may_start_func(profinfo_T *info, ufunc_T *fp, ufunc_T *caller)
562 { 562 {
563 if (do_profiling == PROF_YES) 563 if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL))
564 { 564 {
565 if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL)) 565 info->pi_started_profiling = TRUE;
566 { 566 func_do_profile(fp);
567 info->pi_started_profiling = TRUE; 567 }
568 func_do_profile(fp); 568 if (fp->uf_profiling || (caller != NULL && caller->uf_profiling))
569 } 569 {
570 if (fp->uf_profiling 570 ++fp->uf_tm_count;
571 || (fc->caller != NULL && fc->caller->func->uf_profiling)) 571 profile_start(&info->pi_call_start);
572 { 572 profile_zero(&fp->uf_tm_children);
573 ++fp->uf_tm_count; 573 }
574 profile_start(&info->pi_call_start); 574 script_prof_save(&info->pi_wait_start);
575 profile_zero(&fp->uf_tm_children);
576 }
577 script_prof_save(&info->pi_wait_start);
578 }
579 } 575 }
580 576
581 /* 577 /*
582 * After calling a function: may handle profiling. profile_may_start_func() 578 * After calling a function: may handle profiling. profile_may_start_func()
583 * must have been called previously. 579 * must have been called previously.
584 */ 580 */
585 void 581 void
586 profile_may_end_func(profinfo_T *info, ufunc_T *fp, funccall_T *fc) 582 profile_may_end_func(profinfo_T *info, ufunc_T *fp, ufunc_T *caller)
587 { 583 {
588 profile_end(&info->pi_call_start); 584 profile_end(&info->pi_call_start);
589 profile_sub_wait(&info->pi_wait_start, &info->pi_call_start); 585 profile_sub_wait(&info->pi_wait_start, &info->pi_call_start);
590 profile_add(&fp->uf_tm_total, &info->pi_call_start); 586 profile_add(&fp->uf_tm_total, &info->pi_call_start);
591 profile_self(&fp->uf_tm_self, &info->pi_call_start, &fp->uf_tm_children); 587 profile_self(&fp->uf_tm_self, &info->pi_call_start, &fp->uf_tm_children);
592 if (fc->caller != NULL && fc->caller->func->uf_profiling) 588 if (caller != NULL && caller->uf_profiling)
593 { 589 {
594 profile_add(&fc->caller->func->uf_tm_children, &info->pi_call_start); 590 profile_add(&caller->uf_tm_children, &info->pi_call_start);
595 profile_add(&fc->caller->func->uf_tml_children, &info->pi_call_start); 591 profile_add(&caller->uf_tml_children, &info->pi_call_start);
596 } 592 }
597 if (info->pi_started_profiling) 593 if (info->pi_started_profiling)
598 // make a ":profdel func" stop profiling the function 594 // make a ":profdel func" stop profiling the function
599 fp->uf_profiling = FALSE; 595 fp->uf_profiling = FALSE;
600 } 596 }