Skip to content

Instantly share code, notes, and snippets.

@siers
Last active December 16, 2015 12:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siers/1a480e2c39a200cc3ccb to your computer and use it in GitHub Desktop.
Save siers/1a480e2c39a200cc3ccb to your computer and use it in GitHub Desktop.
Vim startup time profiler
#!/bin/bash
while sleep 0.5; do vim --startuptime "$@" >(./startup-info) +qall; done
# usage: ./collect-times
# Running this will collect startup times in `times' directory.
# It will run it multiple times so that the averages start converging.
# Whenever you remove a plugin, it gets stored as a different version,
# which will be shown at 'watch ./watcher'.
#!/bin/sh
# usage: through collect-times
hash16() {
md5sum | dd bs=16 count=1 2> /dev/null
}
store='times'
version="$store/$1$(find ~/.vim | hash16)"
key='before.*main loop'
key='editing files in windows'
mkdir -p times
find ~/.vim > $version
grep "$key" | sed 's/ .*//' >> $version-time
#!/bin/sh
average() {
ruby -e 'lines = 0
sum = 0.0
$<.each_line do |line|
sum += line.to_i
lines += 1
end
n=10000
puts ((sum/lines*n).to_i.to_f/n)
' "$@"
}
cd times
for id in $(ls | grep -v -- '-time'); do
echo $(average $id-time) : $id : $(cat $id | grep -Eo 'bundle/[^/]+$' | xargs -L1 basename)
done | column -ts : -o : | sort -n
# usage: watch ./watcher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment