Created
November 10, 2014 13:18
-
-
Save k-takata/b0647272fa5825b2c3eb to your computer and use it in GitHub Desktop.
Bench mark of tolower(), split() and map() in VimL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pathext = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.tcl" | |
let s:path_separator = ";" | |
" Time of split | |
let stime = reltime() | |
for i in range(1, 1000) | |
let s:path_extensions = split(tolower(pathext), s:path_separator) | |
endfor | |
echo reltimestr(reltime(stime)) . " (split) " . len(s:path_extensions) | |
echo s:path_extensions | |
unlet s:path_extensions | |
" Time of split + map | |
let stime = reltime() | |
for i in range(1, 1000) | |
let s:path_extensions = map(split(pathext, s:path_separator), 'tolower(v:val)') | |
endfor | |
echo reltimestr(reltime(stime)) . " (split + map) " . len(s:path_extensions) | |
echo s:path_extensions | |
unlet s:path_extensions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result:
Using map() is 20 times slower.