Vim script の処理時間を計測する
reltime() と reltimestr() の組み合わせで出来るぽいです。
[ソース]
command! -bar TimerStart let start_time = reltime() command! -bar TimerEnd echo reltimestr(reltime(start_time)) | unlet start_time function! s:test1() TimerStart for n in range(500) call extend(copy(l:), g:, "keep") endfor TimerEnd endfunction function! s:test2() TimerStart for n in range(500) call extend(copy(g:), l:, "force") endfor TimerEnd endfunction function! s:main() call s:test1() call s:test2() endfunction call s:main()
[出力]
1.176019 1.114632
Scope Exit がほしくなる。
あと使用する場合は +reltime と +float が必要になります。