Created
August 25, 2010 17:03
-
-
Save bga/549865 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; | |
_speedTest( | |
[ | |
function(n) | |
{ | |
var a = 0; | |
var i = n; while(i--) | |
{ | |
a = (25173*a + 13849)&0xffff; | |
a -= 0x7fff; | |
if(a < 0) a = -a; | |
} | |
}, | |
function(n) | |
{ | |
var a = 0; | |
var i = n; while(i--) | |
{ | |
a = (25173*a + 13849)&0xffff; | |
a -= 0x7fff; | |
a = (a^(a >> 31)) - (a >> 31); | |
} | |
}, | |
function(n) | |
{ | |
var a = 0; | |
var i = n; while(i--) | |
{ | |
a = (25173*a + 13849)&0xffff; | |
a -= 0x7fff; | |
a = _abs(a); | |
} | |
} | |
], | |
100000000 | |
); | |
/* | |
ie7 300000 | |
0: 330 ms | |
1: 371 ms | |
2: 1021 ms | |
chrome5 10000000 | |
0: 522 ms | |
1: 444 ms | |
2: 780 ms | |
opera10.60 20000000 | |
0: 837 ms | |
1: 666 ms | |
2: 1320 ms | |
ff3.6 10000000 | |
0: 7496 ms | |
1: 9101 ms | |
2: 8357 ms | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment