Created
September 11, 2014 01:47
-
-
Save dead-horse/e638c05babbd224163e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function test(path) { | |
return path.split('/').join('/'); | |
} | |
var path1 = 'first'; | |
var path2 = 'second'; | |
var longPath = '.././home//Users/name/git/project/lib/abc/def/zzz.js'; | |
var plusPath = path1 + '/' + path2 + '/' + longPath; | |
var constantPath = 'first/second/.././home//Users/name/git/project/lib/abc/def/zzz.js'; | |
var length = 1000000; | |
console.time('plusPath'); | |
for (var i = 0; i < length; i++) { | |
test(plusPath); | |
} | |
console.timeEnd('plusPath'); | |
console.time('constantPath'); | |
for (var i = 0; i < length; i++) { | |
test(constantPath); | |
} | |
console.timeEnd('constantPath'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
plusPath: 1016ms
constantPath: 203ms