Skip to content

Instantly share code, notes, and snippets.

@machakann
Created February 15, 2016 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machakann/711c4c70c758731b807c to your computer and use it in GitHub Desktop.
Save machakann/711c4c70c758731b807c to your computer and use it in GitHub Desktop.
vim-jp/issues #822
function! Tic()
let s:starttime = reltime()
endfunction
function! Toc()
return reltimestr(reltime(s:starttime))
endfunction
command! -nargs=0 Tic call Tic()
command! -nargs=0 Toc echomsg Toc()
function! Profile_matchfuncs() abort
let str = ''
for c in split('abcdefghijklmno', '\zs')
let str .= repeat(c, 1000)
endfor
let pattern = 'noo'
echomsg '*** matchstr, match, matchend ***'
Tic
for i in range(1, 1000)
let result = [matchstr(str, pattern), match(str, pattern), matchend(str, pattern)]
endfor
Toc
echomsg '*** match, matchend (without packing to a list) ***'
Tic
for i in range(1, 1000)
let result1 = match(str, pattern)
let result2 = matchend(str, pattern)
endfor
Toc
echomsg '*** matchstrpos ***'
Tic
for i in range(1, 1000)
let result = matchstrpos(str, pattern)
endfor
Toc
endfunction
call Profile_matchfuncs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment