# HG changeset patch # User vimboss # Date 1109630899 0 # Node ID 4d53c2a2af94cf7a657d85e27f891b2d53b698c3 # Parent 84c21eb4fc403d3b0805e78fc1b834aa9858c34c updated for version 7.0054 diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.0aa. Last change: 2005 Feb 27 +*todo.txt* For Vim version 7.0aa. Last change: 2005 Feb 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,38 +30,8 @@ be worked on, but only if you sponsor Vi *known-bugs* -------------------- Known bugs and current work ----------------------- -Win32 gettimeofday(): -Or use QueryPerformanceCounter() and QueryPerformanceFrequency() -int gettimeofday (struct timeval *tv, void* tz) - { - union { - LONG_LONG ns100; /*time since 1 Jan 1601 in 100ns units */ - FILETIME ft; - } now; - > - GetSystemTimeAsFileTime (&now.ft); - tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL); - tv->tv_sec = (long) ((now.ns100 - 116444736000000000LL) / 10000000LL); - return (0); - } -Or use GetSystemTime(). -Or: - unsigned long Ticks = 0; - unsigned long Sec =0; - unsigned long Usec = 0; - Ticks = timeGetTime(); - - Sec = Ticks/1000; - Usec = (Ticks - (Sec*1000))*1000; - tp->tv_sec = Sec; - tp->tv_usec = Usec; - -Test11 sometimes fails. Must be a problem with fork() and pipes. - -'sw' is sometimes 8 when using :vimgrep. - -Mingw can use setjmp()? Move code from os_unix.c to common file, adjust -#ifdefs. Try with example from Michaelis. +Mingw code to catch out-of-stack error doesn't work. See MINGW_TRY in +regexp.c. Try with example from Michaelis. Russian helpfile doesn't show up correctly when 'encoding' is koi8-r. (Vassily Ragosin 2005 Feb 16) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -607,6 +607,18 @@ static int function_exists __ARGS((char_ static int builtin_function __ARGS((char_u *name)); #ifdef FEAT_PROFILE static void func_do_profile __ARGS((ufunc_T *fp)); +static void prof_sort_list __ARGS((FILE *fd, ufunc_T **sorttab, int st_len, char *title, int prefer_self)); +static void prof_func_line __ARGS((FILE *fd, int count, proftime_T *total, proftime_T *self, int prefer_self)); +static int +# ifdef __BORLANDC__ + _RTLENTRYF +# endif + prof_total_cmp __ARGS((const void *s1, const void *s2)); +static int +# ifdef __BORLANDC__ + _RTLENTRYF +# endif + prof_self_cmp __ARGS((const void *s1, const void *s2)); #endif static int script_autoload __ARGS((char_u *name)); static char_u *autoload_name __ARGS((char_u *name)); @@ -16125,8 +16137,12 @@ func_dump_profile(fd) int todo; ufunc_T *fp; int i; + ufunc_T **sorttab; + int st_len = 0; todo = func_hashtab.ht_used; + sorttab = (ufunc_T **)alloc((unsigned)(sizeof(ufunc_T) * todo)); + for (hi = func_hashtab.ht_array; todo > 0; ++hi) { if (!HASHITEM_EMPTY(hi)) @@ -16135,6 +16151,9 @@ func_dump_profile(fd) fp = HI2UF(hi); if (fp->uf_profiling) { + if (sorttab != NULL) + sorttab[st_len++] = fp; + if (fp->uf_name[0] == K_SPECIAL) fprintf(fd, "FUNCTION %s()\n", fp->uf_name + 3); else @@ -16150,26 +16169,115 @@ func_dump_profile(fd) for (i = 0; i < fp->uf_lines.ga_len; ++i) { - if (fp->uf_tml_count[i] > 0) - { - fprintf(fd, "%5d ", fp->uf_tml_count[i]); - if (profile_equal(&fp->uf_tml_total[i], - &fp->uf_tml_self[i])) - fprintf(fd, " "); - else - fprintf(fd, "%s ", - profile_msg(&fp->uf_tml_total[i])); - fprintf(fd, "%s ", profile_msg(&fp->uf_tml_self[i])); - } - else - fprintf(fd, " "); + 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 (sorttab != NULL && 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); + } +} + + static void +prof_sort_list(fd, sorttab, st_len, title, prefer_self) + FILE *fd; + ufunc_T **sorttab; + int st_len; + char *title; + int prefer_self; /* when equal print only self time */ +{ + int i; + ufunc_T *fp; + + fprintf(fd, "FUNCTIONS SORTED ON %s TIME\n", title); + fprintf(fd, "count total (s) self (s) function\n"); + for (i = 0; i < 20 && i < st_len; ++i) + { + fp = sorttab[i]; + prof_func_line(fd, fp->uf_tm_count, &fp->uf_tm_total, &fp->uf_tm_self, + prefer_self); + if (fp->uf_name[0] == K_SPECIAL) + fprintf(fd, " %s()\n", fp->uf_name + 3); + else + fprintf(fd, " %s()\n", fp->uf_name); + } + fprintf(fd, "\n"); +} + +/* + * Print the count and times for one function or function line. + */ + static void +prof_func_line(fd, count, total, self, prefer_self) + FILE *fd; + int count; + proftime_T *total; + proftime_T *self; + int prefer_self; /* when equal print only self time */ +{ + if (count > 0) + { + fprintf(fd, "%5d ", count); + if (prefer_self && profile_equal(total, self)) + fprintf(fd, " "); + else + fprintf(fd, "%s ", profile_msg(total)); + if (!prefer_self && profile_equal(total, self)) + fprintf(fd, " "); + else + fprintf(fd, "%s ", profile_msg(self)); + } + else + fprintf(fd, " "); +} + +/* + * Compare function for total time sorting. + */ + static int +#ifdef __BORLANDC__ +_RTLENTRYF +#endif +prof_total_cmp(s1, s2) + const void *s1; + const void *s2; +{ + ufunc_T *p1, *p2; + + p1 = *(ufunc_T **)s1; + p2 = *(ufunc_T **)s2; + return profile_cmp(&p1->uf_tm_total, &p2->uf_tm_total); +} + +/* + * Compare function for self time sorting. + */ + static int +#ifdef __BORLANDC__ +_RTLENTRYF +#endif +prof_self_cmp(s1, s2) + const void *s1; + const void *s2; +{ + ufunc_T *p1, *p2; + + p1 = *(ufunc_T **)s1; + p2 = *(ufunc_T **)s2; + return profile_cmp(&p1->uf_tm_self, &p2->uf_tm_self); +} + #endif /* diff --git a/src/proto/ex_cmds2.pro b/src/proto/ex_cmds2.pro --- a/src/proto/ex_cmds2.pro +++ b/src/proto/ex_cmds2.pro @@ -18,6 +18,7 @@ void profile_add __ARGS((proftime_T *tm, void profile_get_wait __ARGS((proftime_T *tm)); void profile_sub_wait __ARGS((proftime_T *tm, proftime_T *tma)); int profile_equal __ARGS((proftime_T *tm1, proftime_T *tm2)); +int profile_cmp __ARGS((proftime_T *tm1, proftime_T *tm2)); char *profile_msg __ARGS((proftime_T *tm)); void ex_profile __ARGS((exarg_T *eap)); void profile_dump __ARGS((void)); diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro --- a/src/proto/misc1.pro +++ b/src/proto/misc1.pro @@ -87,4 +87,7 @@ void addfile __ARGS((garray_T *gap, char char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags)); void FreeWild __ARGS((int count, char_u **files)); int goto_im __ARGS((void)); +void mch_startjmp __ARGS((void)); +void mch_endjmp __ARGS((void)); +void mch_didjmp __ARGS((void)); /* vim: set ft=c : */