Skip to content

Instantly share code, notes, and snippets.

@azu
Created April 17, 2010 14:34
Show Gist options
  • Save azu/369595 to your computer and use it in GitHub Desktop.
Save azu/369595 to your computer and use it in GitHub Desktop.
// 大体早いもの順
console.time("test");
for(var i=0;i<10000;i++){
var src = "http://example.com/lab/test.js"
src.substring(0,src.lastIndexOf('/')+1)
}
console.timeEnd("test");
console.time("test2");
for(var i=0;i<10000;i++){
var a='http://example.com/lab/test.js'.split("/"); a.pop();
a.join("/") + "/";
}
console.timeEnd("test2");
console.time("test3");
for(var i=0;i<10000;i++){
"http://example.com/lab/test.js".split("/").slice(0,-1).join("/") + "/";
}
console.timeEnd("test3");
console.time("test4");
for(var i=0;i<10000;i++){
/^.+\//('http://example.com/lab/test.js')[0];
}
console.timeEnd("test4");
console.time("test5");
for(var i=0;i<10000;i++){
"http://example.com/lab/test.js".replace(/[^\/]+$/,"")
}
console.timeEnd("test5");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment