Skip to content

Instantly share code, notes, and snippets.

@bga
Created July 18, 2010 16:37
Show Gist options
  • Save bga/480531 to your computer and use it in GitHub Desktop.
Save bga/480531 to your computer and use it in GitHub Desktop.
// you can run it at http://bga.github.com/speedtest/
var _fn = (function()
{
var re = /\d/;
return function(s)
{
re.test(s);
};
})();
var _fn2 = function(s)
{
/\d/.test(s);
};
_speedTest(
[
function(n)
{
var i = n; while(i--)
{
_fn('123');
}
},
function(n)
{
var i = n; while(i--)
{
_fn2('123');
}
}
],
400000
);
/*
ff3.6
0: 703 ms
1: 756 ms
chrome5 n*=10
0: 617 ms
1: 613 ms
ie7
0: 4967 ms
1: 7190 ms
opera10.60 n*=10
0: 1269 ms
1: 1316 ms
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment