Skip to content

Instantly share code, notes, and snippets.

@os0x
Forked from azu/gist:369595
Created April 17, 2010 16:42
Show Gist options
  • Save os0x/369663 to your computer and use it in GitHub Desktop.
Save os0x/369663 to your computer and use it in GitHub Desktop.
// IEでも動くように(実質的には弄ったのはtest4のexecのみ)
var r = [];
var test = new Date*1;
for(var i=0;i<10000;i++){
var src = "http://example.com/lab/test.js"
src.substring(0,src.lastIndexOf('/')+1)
}
r.push(new Date-test);
var test2 = new Date*1;
for(var i=0;i<10000;i++){
var a='http://example.com/lab/test.js'.split("/"); a.pop();
a.join("/") + "/";
}
r.push(new Date-test2);
var test3 = new Date*1;
for(var i=0;i<10000;i++){
"http://example.com/lab/test.js".split("/").slice(0,-1).join("/") + "/";
}
r.push(new Date-test3);
var test4 = new Date*1;
for(var i=0;i<10000;i++){
/^.+\//.exec('http://example.com/lab/test.js')[0];
}
r.push(new Date-test4);
var test5 = new Date*1;
for(var i=0;i<10000;i++){
"http://example.com/lab/test.js".replace(/[^\/]+$/,"")
}
r.push(new Date-test5);
alert(r.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment