Skip to content

Instantly share code, notes, and snippets.

@bga
Created May 19, 2010 21:12
Show Gist options
  • Save bga/406843 to your computer and use it in GitHub Desktop.
Save bga/406843 to your computer and use it in GitHub Desktop.
if(!console)
console = {};
if(!console.log)
console.log = $jb._log;
console.time = $jb._timerBegin;
console.timeEnd = $jb._timerEnd;
var i, n = 300000,
s = ' ';
console.time("1");
i = n; while(i--)
{
s.replace(/\s/g, '');
}
console.timeEnd("1");
console.time("2");
var re = new RegExp(/\s/);
i = n; while(i--)
{
s.replace(re, '');
}
console.timeEnd("2");
/*
ff3.6
1: 3565
2: 1096
2: 1115
1: 3449
chrome4
1: 3955
2: 1129
2: 1266
1: 3898
opera10.53
1: 1923
2: 969
2: 1085
1: 1915
ie7
1: 6950
2: 3505
2: 3565
1: 6650
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment