lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
33c265a
To: vim-dev@vim.org
33c265a
Subject: Patch 7.2.269
33c265a
Fcc: outbox
33c265a
From: Bram Moolenaar <Bram@moolenaar.net>
33c265a
Mime-Version: 1.0
33c265a
Content-Type: text/plain; charset=UTF-8
33c265a
Content-Transfer-Encoding: 8bit
33c265a
------------
33c265a
33c265a
Patch 7.2.269
33c265a
Problem:    Many people struggle to find out why Vim startup is slow.
33c265a
Solution:   Add the --startuptime command line flag.
33c265a
Files:	    runtime/doc/starting.txt, src/globals.h, src/feature.h,
33c265a
	    src/main.c, src/macros.h
33c265a
33c265a
33c265a
*** ../vim-7.2.268/runtime/doc/starting.txt	2008-11-09 13:43:25.000000000 +0100
33c265a
--- runtime/doc/starting.txt	2009-10-25 11:57:51.000000000 +0100
33c265a
***************
33c265a
*** 144,149 ****
33c265a
--- 144,156 ----
33c265a
  			-u NORC			no		    yes
33c265a
  			--noplugin		yes		    no
33c265a
  
33c265a
+ --startuptime={fname}					*--startuptime*
33c265a
+ 		During startup write timing messages to the file {fname}.
33c265a
+ 		This can be used to find out where time is spent while loading
33c265a
+ 		your .vimrc and plugins.
33c265a
+ 		When {fname} already exists new messages are appended.
33c265a
+ 		{only when compiled with this feature}
33c265a
+ 
33c265a
  							*--literal*
33c265a
  --literal	Take file names literally, don't expand wildcards.  Not needed
33c265a
  		for Unix, because Vim always takes file names literally (the
33c265a
***************
33c265a
*** 471,476 ****
33c265a
--- 487,493 ----
33c265a
  		window title and copy/paste using the X clipboard.  This
33c265a
  		avoids a long startup time when running Vim in a terminal
33c265a
  		emulator and the connection to the X server is slow.
33c265a
+ 		See |--startuptime| to find out if affects you.
33c265a
  		Only makes a difference on Unix or VMS, when compiled with the
33c265a
  		|+X11| feature.  Otherwise it's ignored.
33c265a
  		To disable the connection only for specific terminals, see the
33c265a
*** ../vim-7.2.268/src/globals.h	2009-07-29 12:09:49.000000000 +0200
33c265a
--- src/globals.h	2009-10-10 15:14:31.000000000 +0200
33c265a
***************
33c265a
*** 1567,1572 ****
33c265a
--- 1567,1576 ----
33c265a
  /* For undo we need to know the lowest time possible. */
33c265a
  EXTERN time_t starttime;
33c265a
  
33c265a
+ #ifdef STARTUPTIME
33c265a
+ EXTERN FILE *time_fd INIT(= NULL);  /* where to write startup timing */
33c265a
+ #endif
33c265a
+ 
33c265a
  /*
33c265a
   * Some compilers warn for not using a return value, but in some situations we
33c265a
   * can't do anything useful with the value.  Assign to this variable to avoid
33c265a
*** ../vim-7.2.268/src/feature.h	2008-11-09 13:43:25.000000000 +0100
33c265a
--- src/feature.h	2009-10-10 16:16:19.000000000 +0200
33c265a
***************
33c265a
*** 844,853 ****
33c265a
  /* #define DEBUG */
33c265a
  
33c265a
  /*
33c265a
!  * STARTUPTIME		Time the startup process.  Writes a "vimstartup" file
33c265a
!  *			with timestamps.
33c265a
   */
33c265a
! /* #define STARTUPTIME "vimstartup" */
33c265a
  
33c265a
  /*
33c265a
   * MEM_PROFILE		Debugging of memory allocation and freeing.
33c265a
--- 844,857 ----
33c265a
  /* #define DEBUG */
33c265a
  
33c265a
  /*
33c265a
!  * STARTUPTIME		Time the startup process.  Writes a file with
33c265a
!  *			timestamps.
33c265a
   */
33c265a
! #if defined(FEAT_NORMAL) \
33c265a
! 	&& ((defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)) \
33c265a
! 		|| defined(WIN3264))
33c265a
! # define STARTUPTIME 1
33c265a
! #endif
33c265a
  
33c265a
  /*
33c265a
   * MEM_PROFILE		Debugging of memory allocation and freeing.
33c265a
*** ../vim-7.2.268/src/main.c	2009-05-26 22:58:43.000000000 +0200
33c265a
--- src/main.c	2009-10-10 16:18:32.000000000 +0200
33c265a
***************
33c265a
*** 130,139 ****
33c265a
  #endif
33c265a
  
33c265a
  
33c265a
- #ifdef STARTUPTIME
33c265a
- static FILE *time_fd = NULL;
33c265a
- #endif
33c265a
- 
33c265a
  /*
33c265a
   * Different types of error messages.
33c265a
   */
33c265a
--- 130,135 ----
33c265a
***************
33c265a
*** 173,178 ****
33c265a
--- 169,177 ----
33c265a
      char_u	*fname = NULL;		/* file name from command line */
33c265a
      mparm_T	params;			/* various parameters passed between
33c265a
  					 * main() and other functions. */
33c265a
+ #ifdef STARTUPTIME
33c265a
+     int		i;
33c265a
+ #endif
33c265a
  
33c265a
      /*
33c265a
       * Do any system-specific initialisations.  These can NOT use IObuff or
33c265a
***************
33c265a
*** 203,210 ****
33c265a
  #endif
33c265a
  
33c265a
  #ifdef STARTUPTIME
33c265a
!     time_fd = mch_fopen(STARTUPTIME, "a");
33c265a
!     TIME_MSG("--- VIM STARTING ---");
33c265a
  #endif
33c265a
      starttime = time(NULL);
33c265a
  
33c265a
--- 202,216 ----
33c265a
  #endif
33c265a
  
33c265a
  #ifdef STARTUPTIME
33c265a
!     for (i = 1; i < argc; ++i)
33c265a
!     {
33c265a
! 	if (STRNICMP(argv[i], "--startuptime=", 14) == 0)
33c265a
! 	{
33c265a
! 	    time_fd = mch_fopen(argv[i] + 14, "a");
33c265a
! 	    TIME_MSG("--- VIM STARTING ---");
33c265a
! 	    break;
33c265a
! 	}
33c265a
!     }
33c265a
  #endif
33c265a
      starttime = time(NULL);
33c265a
  
33c265a
***************
33c265a
*** 1150,1155 ****
33c265a
--- 1156,1173 ----
33c265a
  	    cursor_on();
33c265a
  
33c265a
  	    do_redraw = FALSE;
33c265a
+ 
33c265a
+ #ifdef STARTUPTIME
33c265a
+ 	    /* Now that we have drawn the first screen all the startup stuff
33c265a
+ 	     * has been done, close any file for startup messages. */
33c265a
+ 	    if (time_fd != NULL)
33c265a
+ 	    {
33c265a
+ 		TIME_MSG("first screen update");
33c265a
+ 		TIME_MSG("--- VIM STARTED ---");
33c265a
+ 		fclose(time_fd);
33c265a
+ 		time_fd = NULL;
33c265a
+ 	    }
33c265a
+ #endif
33c265a
  	}
33c265a
  #ifdef FEAT_GUI
33c265a
  	if (need_mouse_correct)
33c265a
***************
33c265a
*** 1743,1748 ****
33c265a
--- 1761,1770 ----
33c265a
  		    /* already processed, skip */
33c265a
  		}
33c265a
  #endif
33c265a
+ 		else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0)
33c265a
+ 		{
33c265a
+ 		    /* already processed, skip */
33c265a
+ 		}
33c265a
  		else
33c265a
  		{
33c265a
  		    if (argv[0][argv_idx])
33c265a
***************
33c265a
*** 3211,3216 ****
33c265a
--- 3233,3252 ----
33c265a
  
33c265a
  static struct timeval	prev_timeval;
33c265a
  
33c265a
+ # ifdef WIN3264
33c265a
+ /*
33c265a
+  * Windows doesn't have gettimeofday(), although it does have struct timeval.
33c265a
+  */
33c265a
+     static int
33c265a
+ gettimeofday(struct timeval *tv, char *dummy)
33c265a
+ {
33c265a
+     long t = clock();
33c265a
+     tv->tv_sec = t / CLOCKS_PER_SEC;
33c265a
+     tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
33c265a
+     return 0;
33c265a
+ }
33c265a
+ # endif
33c265a
+ 
33c265a
  /*
33c265a
   * Save the previous time before doing something that could nest.
33c265a
   * set "*tv_rel" to the time elapsed so far.
33c265a
***************
33c265a
*** 3299,3318 ****
33c265a
      }
33c265a
  }
33c265a
  
33c265a
- # ifdef WIN3264
33c265a
- /*
33c265a
-  * Windows doesn't have gettimeofday(), although it does have struct timeval.
33c265a
-  */
33c265a
-     int
33c265a
- gettimeofday(struct timeval *tv, char *dummy)
33c265a
- {
33c265a
-     long t = clock();
33c265a
-     tv->tv_sec = t / CLOCKS_PER_SEC;
33c265a
-     tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
33c265a
-     return 0;
33c265a
- }
33c265a
- # endif
33c265a
- 
33c265a
  #endif
33c265a
  
33c265a
  #if defined(FEAT_CLIENTSERVER) || defined(PROTO)
33c265a
--- 3335,3340 ----
33c265a
*** ../vim-7.2.268/src/macros.h	2009-05-17 13:30:58.000000000 +0200
33c265a
--- src/macros.h	2009-10-10 15:19:07.000000000 +0200
33c265a
***************
33c265a
*** 243,249 ****
33c265a
  #endif
33c265a
  
33c265a
  #ifdef STARTUPTIME
33c265a
! # define TIME_MSG(s) time_msg(s, NULL)
33c265a
  #else
33c265a
  # define TIME_MSG(s)
33c265a
  #endif
33c265a
--- 243,249 ----
33c265a
  #endif
33c265a
  
33c265a
  #ifdef STARTUPTIME
33c265a
! # define TIME_MSG(s) { if (time_fd != NULL) time_msg(s, NULL); }
33c265a
  #else
33c265a
  # define TIME_MSG(s)
33c265a
  #endif
33c265a
*** ../vim-7.2.268/src/version.c	2009-11-03 11:43:05.000000000 +0100
33c265a
--- src/version.c	2009-11-03 12:06:31.000000000 +0100
33c265a
***************
33c265a
*** 678,679 ****
33c265a
--- 678,681 ----
33c265a
  {   /* Add new patch number below this line */
33c265a
+ /**/
33c265a
+     269,
33c265a
  /**/
33c265a
33c265a
-- 
33c265a
BEDEVERE: Look!  It's the old man from scene 24 - what's he Doing here?
33c265a
ARTHUR:   He is the keeper of the Bridge.  He asks each traveler five
33c265a
          questions ...
33c265a
GALAHAD:  Three questions.
33c265a
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
33c265a
33c265a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
33c265a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
33c265a
\\\        download, build and distribute -- http://www.A-A-P.org        ///
33c265a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///