mirror of
https://github.com/neovim/neovim.git
synced 2025-12-02 15:03:01 +00:00
vim-patch:8.1.1689: profiling code is spread out
Problem: Profiling code is spread out.
Solution: Move more profiling code to profiler.c. (Yegappan Lakshmanan,
closes vim/vim#4668)
660a10ad41
This commit is contained in:
@@ -7906,82 +7906,6 @@ const char *find_option_end(const char **const arg, int *const opt_flags)
|
||||
return p;
|
||||
}
|
||||
|
||||
/// Dump the profiling results for all functions in file "fd".
|
||||
void func_dump_profile(FILE *fd)
|
||||
{
|
||||
hashitem_T *hi;
|
||||
int todo;
|
||||
ufunc_T *fp;
|
||||
ufunc_T **sorttab;
|
||||
int st_len = 0;
|
||||
|
||||
todo = (int)func_hashtab.ht_used;
|
||||
if (todo == 0) {
|
||||
return; // nothing to dump
|
||||
}
|
||||
|
||||
sorttab = xmalloc(sizeof(ufunc_T *) * (size_t)todo);
|
||||
|
||||
for (hi = func_hashtab.ht_array; todo > 0; ++hi) {
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
--todo;
|
||||
fp = HI2UF(hi);
|
||||
if (fp->uf_prof_initialized) {
|
||||
sorttab[st_len++] = fp;
|
||||
|
||||
if (fp->uf_name[0] == K_SPECIAL) {
|
||||
fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3);
|
||||
} else {
|
||||
fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
|
||||
}
|
||||
if (fp->uf_script_ctx.sc_sid != 0) {
|
||||
bool should_free;
|
||||
const LastSet last_set = (LastSet){
|
||||
.script_ctx = fp->uf_script_ctx,
|
||||
.channel_id = 0,
|
||||
};
|
||||
char *p = (char *)get_scriptname(last_set, &should_free);
|
||||
fprintf(fd, " Defined: %s:%" PRIdLINENR "\n",
|
||||
p, fp->uf_script_ctx.sc_lnum);
|
||||
if (should_free) {
|
||||
xfree(p);
|
||||
}
|
||||
}
|
||||
if (fp->uf_tm_count == 1) {
|
||||
fprintf(fd, "Called 1 time\n");
|
||||
} else {
|
||||
fprintf(fd, "Called %d times\n", fp->uf_tm_count);
|
||||
}
|
||||
fprintf(fd, "Total time: %s\n", profile_msg(fp->uf_tm_total));
|
||||
fprintf(fd, " Self time: %s\n", profile_msg(fp->uf_tm_self));
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, "count total (s) self (s)\n");
|
||||
|
||||
for (int i = 0; i < fp->uf_lines.ga_len; ++i) {
|
||||
if (FUNCLINE(fp, i) == NULL) {
|
||||
continue;
|
||||
}
|
||||
prof_func_line(fd, fp->uf_tml_count[i],
|
||||
&fp->uf_tml_total[i], &fp->uf_tml_self[i], TRUE);
|
||||
fprintf(fd, "%s\n", FUNCLINE(fp, i));
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (st_len > 0) {
|
||||
qsort((void *)sorttab, (size_t)st_len, sizeof(ufunc_T *),
|
||||
prof_total_cmp);
|
||||
prof_sort_list(fd, sorttab, st_len, "TOTAL", FALSE);
|
||||
qsort((void *)sorttab, (size_t)st_len, sizeof(ufunc_T *),
|
||||
prof_self_cmp);
|
||||
prof_sort_list(fd, sorttab, st_len, "SELF", TRUE);
|
||||
}
|
||||
|
||||
xfree(sorttab);
|
||||
}
|
||||
|
||||
/// Return the autoload script name for a function or variable name
|
||||
/// Caller must make sure that "name" contains AUTOLOAD_CHAR.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user