Created
May 27, 2015 14:38
-
-
Save dahu/c590c073fb540619c9a4 to your computer and use it in GitHub Desktop.
Plot Vim's Startup Time data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Barry Arthur May 2015 | |
" Plot Vim's startup time data | |
" | |
" Install in ~/.vim/plugin/ | |
" | |
" Usage: | |
" vim --startuptime foo +q | |
" vim -c "Startuptime foo" +q | |
function! Startuptime(file) | |
let data = [] | |
for l in readfile(a:file) | |
if l !~ '^\d' | |
continue | |
endif | |
let l = substitute(l, '^\(\d\+\.\d\+\):*', '\1:', '') | |
call add(data, l) | |
endfor | |
call writefile(data, a:file) | |
call Gnuplot(a:file) | |
endfunction | |
function! Gnuplot(file) | |
let now = strftime('%Y-%m-%d.%H:%M:%S') | |
let cmds = [ | |
\ 'reset' | |
\, 'unset colorbox' | |
\, 'set terminal png size 1800,1800 crop enhanced font "/usr/share/fonts/truetype/times.ttf,30" dashlength 2' | |
\, 'set termoption linewidth 3' | |
\, 'set output "vim-startuptime-' . now . '.png"' | |
\, 'set datafile sep ":"' | |
\, 'set style line 1 lc rgb "#0060ad" lt 1 lw 2 pt 7 ps 1.5' | |
\, 'set xlabel "Time [ms]"' | |
\, 'plot "' . a:file . '" using 1:2 title "Vim Startuptime ' . now . '", "" using 1:2:3 title "" with labels offset 0,char 1' | |
\] | |
echo system('gnuplot -e ' . shellescape(join(cmds, " ; "))) | |
endfunction | |
command! -nargs=1 -complete=file Startuptime call Startuptime(<q-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment