I've got alot of plugins enabled when using vim which I've collected over the years. I'm a bit fed up with how long vim takes to start now so I'd like to profile it's startup and see which of the many plugins I have are responsible. Is there anyway to profile vim startup or script running? Ideally I'd like to know how long vim spent in each vim script it loads.
+2
A:
If you're loading your plugins from a .vimrc file, what you could do is put a q
on some line part way through the file to make it quit so you can use a process timer, like the unix time
command. More thoroughly, this would look like:
- backup existing
.vimrc
file - comment out all but a select number of plugins
- insert a
q
line - call
time vim
repeteadly and average - restore backup
This is not elegant but I think it will get the job done.
David Berger
2009-11-06 14:17:31
Hmm, not bad in a pinch. I've already got my vimrc split into lots of seperate files so shouldn't be too hard to automate.
Benj
2009-11-06 14:21:48
+12
A:
You could run vim -V
, pipe the output through a utility that adds timestamps and analyze the output. This command lines does this, e.g.:
vim -V 2>&1 | perl -MTime::HiRes=time -ne 'print time, ": ", $_' | tee vilog
You might have to blindly type :q to get back to your prompt. Afterwards, you should find the file vilog
in your current directory with hires timestamps at the beginning of each line.
If you can do with a granularity of a second, you can do this:
vim -V 2>&1 | perl -ne 'print time, ": ", $_' | tee vilog
innaM
2009-11-06 15:16:23
+4
A:
I refined the vim -V solution by Manni to show the delta time:
vim -V 2>&1 | perl -MTime::HiRes=time -ne '$a = time unless defined $a; print time - $a, ": ", $_' | tee vilog
Benj
2009-11-06 16:06:32