home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.2 / 7.2.269 < prev    next >
Encoding:
Internet Message Format  |  2009-11-02  |  7.0 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 7.2.269
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.2.269
  11. Problem:    Many people struggle to find out why Vim startup is slow.
  12. Solution:   Add the --startuptime command line flag.
  13. Files:        runtime/doc/starting.txt, src/globals.h, src/feature.h,
  14.         src/main.c, src/macros.h
  15.  
  16.  
  17. *** ../vim-7.2.268/runtime/doc/starting.txt    2008-11-09 13:43:25.000000000 +0100
  18. --- runtime/doc/starting.txt    2009-10-25 11:57:51.000000000 +0100
  19. ***************
  20. *** 144,149 ****
  21. --- 144,156 ----
  22.               -u NORC            no            yes
  23.               --noplugin        yes            no
  24.   
  25. + --startuptime={fname}                    *--startuptime*
  26. +         During startup write timing messages to the file {fname}.
  27. +         This can be used to find out where time is spent while loading
  28. +         your .vimrc and plugins.
  29. +         When {fname} already exists new messages are appended.
  30. +         {only when compiled with this feature}
  31.                               *--literal*
  32.   --literal    Take file names literally, don't expand wildcards.  Not needed
  33.           for Unix, because Vim always takes file names literally (the
  34. ***************
  35. *** 471,476 ****
  36. --- 487,493 ----
  37.           window title and copy/paste using the X clipboard.  This
  38.           avoids a long startup time when running Vim in a terminal
  39.           emulator and the connection to the X server is slow.
  40. +         See |--startuptime| to find out if affects you.
  41.           Only makes a difference on Unix or VMS, when compiled with the
  42.           |+X11| feature.  Otherwise it's ignored.
  43.           To disable the connection only for specific terminals, see the
  44. *** ../vim-7.2.268/src/globals.h    2009-07-29 12:09:49.000000000 +0200
  45. --- src/globals.h    2009-10-10 15:14:31.000000000 +0200
  46. ***************
  47. *** 1567,1572 ****
  48. --- 1567,1576 ----
  49.   /* For undo we need to know the lowest time possible. */
  50.   EXTERN time_t starttime;
  51.   
  52. + #ifdef STARTUPTIME
  53. + EXTERN FILE *time_fd INIT(= NULL);  /* where to write startup timing */
  54. + #endif
  55.   /*
  56.    * Some compilers warn for not using a return value, but in some situations we
  57.    * can't do anything useful with the value.  Assign to this variable to avoid
  58. *** ../vim-7.2.268/src/feature.h    2008-11-09 13:43:25.000000000 +0100
  59. --- src/feature.h    2009-10-10 16:16:19.000000000 +0200
  60. ***************
  61. *** 844,853 ****
  62.   /* #define DEBUG */
  63.   
  64.   /*
  65. !  * STARTUPTIME        Time the startup process.  Writes a "vimstartup" file
  66. !  *            with timestamps.
  67.    */
  68. ! /* #define STARTUPTIME "vimstartup" */
  69.   
  70.   /*
  71.    * MEM_PROFILE        Debugging of memory allocation and freeing.
  72. --- 844,857 ----
  73.   /* #define DEBUG */
  74.   
  75.   /*
  76. !  * STARTUPTIME        Time the startup process.  Writes a file with
  77. !  *            timestamps.
  78.    */
  79. ! #if defined(FEAT_NORMAL) \
  80. !     && ((defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)) \
  81. !         || defined(WIN3264))
  82. ! # define STARTUPTIME 1
  83. ! #endif
  84.   
  85.   /*
  86.    * MEM_PROFILE        Debugging of memory allocation and freeing.
  87. *** ../vim-7.2.268/src/main.c    2009-05-26 22:58:43.000000000 +0200
  88. --- src/main.c    2009-10-10 16:18:32.000000000 +0200
  89. ***************
  90. *** 130,139 ****
  91.   #endif
  92.   
  93.   
  94. - #ifdef STARTUPTIME
  95. - static FILE *time_fd = NULL;
  96. - #endif
  97.   /*
  98.    * Different types of error messages.
  99.    */
  100. --- 130,135 ----
  101. ***************
  102. *** 173,178 ****
  103. --- 169,177 ----
  104.       char_u    *fname = NULL;        /* file name from command line */
  105.       mparm_T    params;            /* various parameters passed between
  106.                        * main() and other functions. */
  107. + #ifdef STARTUPTIME
  108. +     int        i;
  109. + #endif
  110.   
  111.       /*
  112.        * Do any system-specific initialisations.  These can NOT use IObuff or
  113. ***************
  114. *** 203,210 ****
  115.   #endif
  116.   
  117.   #ifdef STARTUPTIME
  118. !     time_fd = mch_fopen(STARTUPTIME, "a");
  119. !     TIME_MSG("--- VIM STARTING ---");
  120.   #endif
  121.       starttime = time(NULL);
  122.   
  123. --- 202,216 ----
  124.   #endif
  125.   
  126.   #ifdef STARTUPTIME
  127. !     for (i = 1; i < argc; ++i)
  128. !     {
  129. !     if (STRNICMP(argv[i], "--startuptime=", 14) == 0)
  130. !     {
  131. !         time_fd = mch_fopen(argv[i] + 14, "a");
  132. !         TIME_MSG("--- VIM STARTING ---");
  133. !         break;
  134. !     }
  135. !     }
  136.   #endif
  137.       starttime = time(NULL);
  138.   
  139. ***************
  140. *** 1150,1155 ****
  141. --- 1156,1173 ----
  142.           cursor_on();
  143.   
  144.           do_redraw = FALSE;
  145. + #ifdef STARTUPTIME
  146. +         /* Now that we have drawn the first screen all the startup stuff
  147. +          * has been done, close any file for startup messages. */
  148. +         if (time_fd != NULL)
  149. +         {
  150. +         TIME_MSG("first screen update");
  151. +         TIME_MSG("--- VIM STARTED ---");
  152. +         fclose(time_fd);
  153. +         time_fd = NULL;
  154. +         }
  155. + #endif
  156.       }
  157.   #ifdef FEAT_GUI
  158.       if (need_mouse_correct)
  159. ***************
  160. *** 1743,1748 ****
  161. --- 1761,1770 ----
  162.               /* already processed, skip */
  163.           }
  164.   #endif
  165. +         else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0)
  166. +         {
  167. +             /* already processed, skip */
  168. +         }
  169.           else
  170.           {
  171.               if (argv[0][argv_idx])
  172. ***************
  173. *** 3211,3216 ****
  174. --- 3233,3252 ----
  175.   
  176.   static struct timeval    prev_timeval;
  177.   
  178. + # ifdef WIN3264
  179. + /*
  180. +  * Windows doesn't have gettimeofday(), although it does have struct timeval.
  181. +  */
  182. +     static int
  183. + gettimeofday(struct timeval *tv, char *dummy)
  184. + {
  185. +     long t = clock();
  186. +     tv->tv_sec = t / CLOCKS_PER_SEC;
  187. +     tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
  188. +     return 0;
  189. + }
  190. + # endif
  191.   /*
  192.    * Save the previous time before doing something that could nest.
  193.    * set "*tv_rel" to the time elapsed so far.
  194. ***************
  195. *** 3299,3318 ****
  196.       }
  197.   }
  198.   
  199. - # ifdef WIN3264
  200. - /*
  201. -  * Windows doesn't have gettimeofday(), although it does have struct timeval.
  202. -  */
  203. -     int
  204. - gettimeofday(struct timeval *tv, char *dummy)
  205. - {
  206. -     long t = clock();
  207. -     tv->tv_sec = t / CLOCKS_PER_SEC;
  208. -     tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
  209. -     return 0;
  210. - }
  211. - # endif
  212.   #endif
  213.   
  214.   #if defined(FEAT_CLIENTSERVER) || defined(PROTO)
  215. --- 3335,3340 ----
  216. *** ../vim-7.2.268/src/macros.h    2009-05-17 13:30:58.000000000 +0200
  217. --- src/macros.h    2009-10-10 15:19:07.000000000 +0200
  218. ***************
  219. *** 243,249 ****
  220.   #endif
  221.   
  222.   #ifdef STARTUPTIME
  223. ! # define TIME_MSG(s) time_msg(s, NULL)
  224.   #else
  225.   # define TIME_MSG(s)
  226.   #endif
  227. --- 243,249 ----
  228.   #endif
  229.   
  230.   #ifdef STARTUPTIME
  231. ! # define TIME_MSG(s) { if (time_fd != NULL) time_msg(s, NULL); }
  232.   #else
  233.   # define TIME_MSG(s)
  234.   #endif
  235. *** ../vim-7.2.268/src/version.c    2009-11-03 11:43:05.000000000 +0100
  236. --- src/version.c    2009-11-03 12:06:31.000000000 +0100
  237. ***************
  238. *** 678,679 ****
  239. --- 678,681 ----
  240.   {   /* Add new patch number below this line */
  241. + /**/
  242. +     269,
  243.   /**/
  244.  
  245. -- 
  246. BEDEVERE: Look!  It's the old man from scene 24 - what's he Doing here?
  247. ARTHUR:   He is the keeper of the Bridge.  He asks each traveler five
  248.           questions ...
  249. GALAHAD:  Three questions.
  250.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  251.  
  252.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  253. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  254. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  255.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  256.