Skip to content

tomtom/startup_profile_vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

With the introduction of the autoload directory, plugins were often 
split into several separate files. The downside is that it isn't always 
that obvious which files are actually loaded on startup.

You can use the :scriptnames command to get a list of files that were 
loaded during startup. This list tells you the order in which the files 
were loaded but it doesn't tell you much about the impact of that script 
on startup time. So what you actually want is a list of the scripts 
including certain indicators of how long it took to process a script.

From version 7.3 on, vim has a |--startuptime| command-line option that can be 
used to achieve something similar.

This macro creates a CSV file, which included the following information:

    * Number of the script
    * Filename
    * Number of line
    * Number of bytes
    * Timestamp
    * Approximate time it took to process the script (actually the time it 
      took until the next script was loaded)

You can open this (semicolon-separated) CSV in any spreadsheet 
application, sort the data etc.

The list can serve as a starting point for optimizing your startup time, 
for example by delaying certain calls to functions in autoload files or 
by making use of the AsNeeded plugin

In order to activate the macro, check the value of g:startup_profile_csv 
in the source code and temporarily insert the following line(s) at the 
beginning of your |vimrc| file: >

    " Setting g:startup_profile_csv is optional.
    let g:startup_profile_csv = "..."
    runtime macros/startup_profile.vim

The list can serve as a starting point for optimizing your startup time, 
e.g. by delaying certain calls to functions in autoload files or by 
making use of the AsNeeded plugin (vimscript #915).

Depending on your system configuration and the speed of your hard drive, 
seeking for files or, e.g., creating menu entries may prove to be costly 
with respect to startup time.

This script itself changes startup time because it accesses every script 
in order to find out its size and the number of lines.

This script logs all files until the |VimEnter| event is triggered. It 
is assumed that any files loaded thereafter are specific to the file 
being edited.

Related~

    * AsNeeded plugin: http://www.vim.org/scripts/script.php?script_id=915
    * Wiki page: http://vim.wikia.com/wiki/Optimize_startup_time_by_logging_the_sourced_vimscript_files



-----------------------------------------------------------------------

Status:  Works for me (there may be some minor quirks)
Install: See http://github.com/tomtom/vimtlib/blob/master/INSTALL.TXT
See http://github.com/tomtom for related plugins.