Created
August 25, 2010 17:05
-
-
Save bga/549866 to your computer and use it in GitHub Desktop.
This file contains 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
var _abs = Math.abs; | |
var _floor = Math.floor; | |
var _rand = Math.random; | |
_speedTest( | |
[ | |
function(n) | |
{ | |
var i = n; while(i--) | |
{ | |
var a = 100*_rand(); | |
a = a|0; | |
if(a < 0) a = -a; | |
} | |
}, | |
function(n) | |
{ | |
var i = n; while(i--) | |
{ | |
var a = 100*_rand(); | |
a = (a^(a >> 31)) - (a >> 31); | |
} | |
}, | |
function(n) | |
{ | |
var i = n; while(i--) | |
{ | |
var a = 100*_rand(); | |
a = _abs(a)|0; | |
} | |
}, | |
function(n) | |
{ | |
var i = n; while(i--) | |
{ | |
var a = 100*_rand(); | |
a = _floor(_abs(a)); | |
} | |
} | |
], | |
100000000 | |
); | |
/* | |
chrome 5 10000000 | |
0: 1832 ms | |
1: 2536 ms | |
2: 2511 ms | |
3: 3087 ms | |
ff3.6 1000000 | |
0: 1194 ms | |
1: 1902 ms | |
2: 1223 ms | |
3: 1155 ms | |
opera 10.60 5000000 | |
0: 1427 ms | |
1: 1451 ms | |
2: 2529 ms | |
3: 2894 ms | |
ie7 1000000 | |
0: 3204 ms | |
1: 3405 ms | |
2: 5698 ms | |
3: 8543 ms | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment