To: vim-dev@vim.org Subject: Patch 7.0.157 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.0.157 Problem: When a function is used recursively the profiling information is invalid. (Mikolaj Machowski) Solution: Put the start time on the stack instead of in the function. Files: src/eval.c *** ../vim-7.0.156/src/eval.c Wed Nov 1 15:31:02 2006 --- src/eval.c Wed Nov 1 13:39:52 2006 *************** *** 166,172 **** int uf_tm_count; /* nr of calls */ proftime_T uf_tm_total; /* time spend in function + children */ proftime_T uf_tm_self; /* time spend in function itself */ - proftime_T uf_tm_start; /* time at function call */ proftime_T uf_tm_children; /* time spent in children this call */ /* profiling the function per line */ int *uf_tml_count; /* nr of times line was executed */ --- 166,171 ---- *************** *** 19764,19769 **** --- 19763,19769 ---- char_u *name; #ifdef FEAT_PROFILE proftime_T wait_start; + proftime_T call_start; #endif /* If depth of calling is getting too high, don't execute the function */ *************** *** 19943,19949 **** || (fc.caller != NULL && &fc.caller->func->uf_profiling)) { ++fp->uf_tm_count; ! profile_start(&fp->uf_tm_start); profile_zero(&fp->uf_tm_children); } script_prof_save(&wait_start); --- 19943,19949 ---- || (fc.caller != NULL && &fc.caller->func->uf_profiling)) { ++fp->uf_tm_count; ! profile_start(&call_start); profile_zero(&fp->uf_tm_children); } script_prof_save(&wait_start); *************** *** 19973,19986 **** if (do_profiling == PROF_YES && (fp->uf_profiling || (fc.caller != NULL && &fc.caller->func->uf_profiling))) { ! profile_end(&fp->uf_tm_start); ! profile_sub_wait(&wait_start, &fp->uf_tm_start); ! profile_add(&fp->uf_tm_total, &fp->uf_tm_start); ! profile_self(&fp->uf_tm_self, &fp->uf_tm_start, &fp->uf_tm_children); if (fc.caller != NULL && &fc.caller->func->uf_profiling) { ! profile_add(&fc.caller->func->uf_tm_children, &fp->uf_tm_start); ! profile_add(&fc.caller->func->uf_tml_children, &fp->uf_tm_start); } } #endif --- 19973,19986 ---- if (do_profiling == PROF_YES && (fp->uf_profiling || (fc.caller != NULL && &fc.caller->func->uf_profiling))) { ! profile_end(&call_start); ! profile_sub_wait(&wait_start, &call_start); ! profile_add(&fp->uf_tm_total, &call_start); ! profile_self(&fp->uf_tm_self, &call_start, &fp->uf_tm_children); if (fc.caller != NULL && &fc.caller->func->uf_profiling) { ! profile_add(&fc.caller->func->uf_tm_children, &call_start); ! profile_add(&fc.caller->func->uf_tml_children, &call_start); } } #endif *** ../vim-7.0.156/src/version.c Wed Nov 1 18:10:36 2006 --- src/version.c Wed Nov 1 18:32:42 2006 *************** *** 668,669 **** --- 668,671 ---- { /* Add new patch number below this line */ + /**/ + 157, /**/ -- hundred-and-one symptoms of being an internet addict: 140. You'd rather catch a score on the web than watch the game as it is being played on tv. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///