Reputation: 55
I try to compare two versions of a same vim function. How can I time them and compare?
What I'm looking for is a simple way to benchmark the first version of the function against the second one, with some kind of precise time echo.
Thank you!
Upvotes: 2
Views: 864
Reputation: 196751
Here is a simple demonstration of the use of :help reltime()
and :help reltimestr()
:
function! Foo()
" do your thing
for i in range(1,8)
let @a = i
endfor
endfunction
" save current time
let start_time = reltime()
" call your function
call Foo()
" echo elapsed time expressed in seconds
echo "elapsed time:" reltimestr(reltime(start_time))
It should output something like:
elapsed time: 0.000165
Upvotes: 8