Skip to content

Instantly share code, notes, and snippets.

@cohama
Created June 15, 2013 06:23
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 cohama/5787135 to your computer and use it in GitHub Desktop.
Save cohama/5787135 to your computer and use it in GitHub Desktop.
let s:V = vital#of('vital')
let s:S = s:V.import('Data.String')
let start = reltime()
let test1 = s:S.substitute_last(repeat('vim is vital', 1000), 'i', 'ooo')
let elapsed = reltimestr(reltime(start))
echo "substitute last" elapsed
let start = reltime()
let test2 = substitute(repeat('vim is vital', 1000), 'i', 'ooo', '')
let elapsed = reltimestr(reltime(start))
echo "substitute first" elapsed
let start = reltime()
let test3 = substitute(repeat('vim is vital', 1000), '.*\zsi', 'ooo', '')
let elapsed = reltimestr(reltime(start))
let verify = (test1 ==# test3)
echo "substitute deris" elapsed verify
@cohama
Copy link
Author

cohama commented Jun 15, 2013

substitute last 2.417154
substitute first 0.000038
substitute deris 0.000844 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment