Thursday, October 21, 2010

Re: time a script

Reply to message «time a script»,
sent 01:08:39 22 October 2010, Friday
by Bee:

Try looking at :profile command:
profile start /path/to/profile.log
profile func *
" run something
qa!
Note not to delete functions before exiting vim.
BTW, what exactly were you passing as a:fu? If it is a function reference (or a
string with function name), then you should have used the following function:
function Time(funcref, ...)
let start=reltime()
call call(a:funcref, a:000, {})
echo reltimestr(reltime(start))
endfunction

Original message:
> I have used reltime() inside a function and it works.
>
> I thought to make a wrapper for the timer, but it only returns the
> time to run the line with execute and not the passed function.
>
> function! Time(fu)
> let start = reltime()
> execute a:fu
> echo reltimestr(reltime(start))
> endfun
>
> Is there a way to make this work?
> -Bill

No comments: