Add a way to profile Vim bindings

This commit is contained in:
ZyX 2014-09-05 08:35:20 +04:00
parent d569c0b3dd
commit 60fb311463
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,21 @@
****************************************
Tips and tricks for powerline developers
****************************************
Profiling powerline in Vim
==========================
Given that current directory is the root of the powerline repository the
following command may be used:
.. code-block:: sh
vim --cmd 'let g:powerline_pyeval="powerline#debug#profile_pyeval"' \
--cmd 'set rtp=powerline/bindings/vim' \
-c 'runtime! plugin/powerline.vim' \
{other arguments if needed}
After some time run ``:WriteProfiling {filename}`` Vim command. Currently this
only works with recent Vim and python-2*. It should be easy to modify
:file:`powerline/bindings/vim/autoload/powerline/debug.vim` to suit other
needs.

View File

@ -0,0 +1,20 @@
python import cProfile
python powerline_pr = cProfile.Profile()
function powerline#debug#profile_pyeval(s)
python powerline_pr.enable()
try
let ret = pyeval(a:s)
finally
python powerline_pr.disable()
endtry
return ret
endfunction
function powerline#debug#write_profile(fname)
python import vim
python powerline_pr.dump_stats(vim.eval('a:fname'))
python powerline_pr = cProfile.Profile()
endfunction
command -nargs=1 -complete=file WriteProfiling :call powerline#debug#write_profile(<q-args>)