diff options
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 22 | ||||
-rw-r--r-- | src/nvim/globals.h | 2 | ||||
-rw-r--r-- | src/nvim/main.c | 10 | ||||
-rw-r--r-- | src/nvim/profile.c | 9 | ||||
-rw-r--r-- | src/nvim/profile.h | 8 | ||||
-rw-r--r-- | src/nvim/version.c | 4 |
7 files changed, 16 insertions, 41 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index e72dd60dcf..77f327c124 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9731,9 +9731,7 @@ static void f_has(typval_T *argvars, typval_T *rettv) "cmdline_info", "signs", "smartindent", -#ifdef STARTUPTIME "startuptime", -#endif "statusline", "spell", "syntax", diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index dc118bb5fe..afbb3b40f1 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2261,10 +2261,6 @@ do_source ( void *save_funccalp; int save_debug_break_level = debug_break_level; scriptitem_T *si = NULL; -#ifdef STARTUPTIME - proftime_T tv_rel; - proftime_T tv_start; -#endif proftime_T wait_start; p = expand_env_save(fname); @@ -2393,10 +2389,13 @@ do_source ( firstline = p; } -#ifdef STARTUPTIME - if (time_fd != NULL) - time_push(&tv_rel, &tv_start); -#endif + // start measuring script load time if --startuptime was passed and + // time_fd was successfully opened afterwards. + proftime_T rel_time; + proftime_T start_time; + if (time_fd != NULL) { + time_push(&rel_time, &start_time); + } if (do_profiling == PROF_YES) prof_child_enter(&wait_start); /* entering a child now */ @@ -2490,13 +2489,12 @@ do_source ( smsg((char_u *)_("continuing in %s"), sourcing_name); verbose_leave(); } -#ifdef STARTUPTIME + if (time_fd != NULL) { vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname); - time_msg((char *)IObuff, &tv_start); - time_pop(tv_rel); + time_msg((char *)IObuff, &start_time); + time_pop(rel_time); } -#endif /* * After a "finish" in debug mode, need to break at first command of next diff --git a/src/nvim/globals.h b/src/nvim/globals.h index b3ed2f7239..f9d5a766c8 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1207,9 +1207,7 @@ EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP")); /* For undo we need to know the lowest time possible. */ EXTERN time_t starttime; -#ifdef STARTUPTIME EXTERN FILE *time_fd INIT(= NULL); /* where to write startup timing */ -#endif /* * Some compilers warn for not using a return value, but in some situations we diff --git a/src/nvim/main.c b/src/nvim/main.c index c8b7b10354..0c474c9ad4 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -711,7 +711,6 @@ main_loop ( do_redraw = FALSE; -#ifdef STARTUPTIME /* Now that we have drawn the first screen all the startup stuff * has been done, close any file for startup messages. */ if (time_fd != NULL) { @@ -720,7 +719,6 @@ main_loop ( fclose(time_fd); time_fd = NULL; } -#endif } /* @@ -1467,16 +1465,14 @@ static void init_params(mparm_T *paramp, int argc, char **argv) */ static void init_startuptime(mparm_T *paramp) { -#ifdef STARTUPTIME - int i; - for (i = 1; i < paramp->argc; ++i) { + for (int i = 1; i < paramp->argc; i++) { if (STRICMP(paramp->argv[i], "--startuptime") == 0 && i + 1 < paramp->argc) { time_fd = mch_fopen(paramp->argv[i + 1], "a"); time_start("--- VIM STARTING ---"); break; } } -#endif + starttime = time(NULL); } @@ -2221,9 +2217,7 @@ static void usage(void) main_msg(_("-s <scriptin>\tRead Normal mode commands from file <scriptin>")); main_msg(_("-w <scriptout>\tAppend all typed commands to file <scriptout>")); main_msg(_("-W <scriptout>\tWrite all typed commands to file <scriptout>")); -#ifdef STARTUPTIME main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>")); -#endif main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo")); main_msg(_("--api-msgpack-metadata\tDump API metadata information and exit")); main_msg(_("-h or --help\tPrint Help (this message) and exit")); diff --git a/src/nvim/profile.c b/src/nvim/profile.c index 45dfab426f..ffc62c3c7e 100644 --- a/src/nvim/profile.c +++ b/src/nvim/profile.c @@ -6,9 +6,7 @@ #include "nvim/os/time.h" #include "nvim/func_attr.h" -#ifdef STARTUPTIME -#include "nvim/vim.h" // for the global `time_fd` -#endif +#include "nvim/globals.h" // for the global `time_fd` (startuptime) #ifdef INCLUDE_GENERATED_DECLARATIONS # include "profile.c.generated.h" @@ -187,8 +185,7 @@ int profile_cmp(proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST return sgn64((int64_t)(tm2 - tm1)); } -#ifdef STARTUPTIME - +/// globals for use in the startuptime related functionality (time_*). static proftime_T g_start_time; static proftime_T g_prev_time; @@ -282,5 +279,3 @@ void time_msg(const char *mesg, const proftime_T *start) g_prev_time = now; fprintf(time_fd, ": %s\n", mesg); } - -#endif diff --git a/src/nvim/profile.h b/src/nvim/profile.h index bca83ba90d..7b378577ce 100644 --- a/src/nvim/profile.h +++ b/src/nvim/profile.h @@ -6,13 +6,9 @@ typedef uint64_t proftime_T; -#ifdef STARTUPTIME #define TIME_MSG(s) do { \ - if (time_fd != NULL) time_msg(s, NULL); \ -} while (0) -#else -#define TIME_MSG(s) -#endif + if (time_fd != NULL) time_msg(s, NULL); \ + } while (0) #ifdef INCLUDE_GENERATED_DECLARATIONS # include "profile.h.generated.h" diff --git a/src/nvim/version.c b/src/nvim/version.c index 183e643753..c10fc970ab 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -145,11 +145,7 @@ static char *(features[]) = { "+scrollbind", "+signs", "+smartindent", -#ifdef STARTUPTIME "+startuptime", -#else // ifdef STARTUPTIME - "-startuptime", -#endif // ifdef STARTUPTIME "+statusline", "+syntax", "+tag_binary", |