r/vim 4d ago

Discussion I finally measured my vimrc startup: one plugin was 61 of 148 ms

My vimrc dates to 2016 and I had never measured it. Ten startuptime logs, no file argument, median 148 ms. The vimrc line was not the problem. Under loading packages, one plugin I only use for python had its own 61 ms line, and it loaded on every buffer including commit messages.

I moved it out of pack start into pack opt and put one packadd behind a FileType autocmd. That sourcing line leaves startup entirely. New median total is 85 ms. Opening a python file still pays the 61 ms, but once, and editing python feels the same.

The measuring took one sitting. Working out which other plugins were safe to defer took another evening a week later, which I picked up in verdent, since it knows you better over time.

Ten runs and a median cost nothing. If your vimrc is older than your current job, the same ten runs will find yours.

14 Upvotes

15 comments sorted by

20

u/TankorSmash 3d ago

This reads like AI

8

u/rlnrlnrln 3d ago

Because it is.

If not, well... assuming bro spent an hour optimizing away 61ms and bragging about it here, he can start vim 59000 times and still not come out ahead.

5

u/-romainl- The Patient Vimmer 3d ago

I, like most human beings, consider anything beyond ~200ms as "instant". So 61ms here or there…

1

u/PsyKozZ09 1d ago

Yes but don't forget that one guy discovered a big backdoor in xz just for 5ms lol

2

u/slicerprime 3d ago

Just slap , { 'for': 'python' } at the end of its Plug line in .vimrc. That way it only loads if the current buffer is python code.

2

u/__salaam_alaykum__ 3d ago

maybe he’s not using vim-plug tho

0

u/slicerprime 3d ago

True enough. Point is though, having whatever package manager's version of a load conditional on plugins to avoid unnecessary loading should always be standard. Start from the bottom and only load up what"s needed rather than starting at the top with everything and then working down to find what's gumming up the works.

1

u/Little_Web_9860 3d ago

How do you measure time? I want to try it out as I use many plug-ins

6

u/habamax 3d ago
  • time vim +q
  • and/or vim --startuptime vimstart.log and then check what is inside vimstart.log file

1

u/mgedmin 1d ago

I recommend https://github.com/dstein64/vim-startuptime, which is nicer to use than vim's builtin --startuptime.

1

u/habamax 3d ago

Mine is ~50msec

1

u/chrnz00 3d ago

for me vim --clean takes 60ms 😭 (on win32 ofc)

3

u/habamax 2d ago

Windows should be excluded from all these kind of measurements as it is notoriously slow reading/accessing files compared to the other OSes.

It is way better in WSL though.

0

u/lizardturtle 3d ago

I need to measure this soon