Created
October 1, 2010 18:14
-
-
Save bga/606615 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
/* | |
this test shows independence loop structure of performance | |
internal asm code become same | |
*/ | |
var m = 1000 | |
, aL = new Array(m) | |
; | |
aL[aL.length - 1] = 1; | |
_speedTest( | |
[ | |
function(n) | |
{ | |
var a = aL, len = a.length; | |
var i = n; while(i--) | |
{ | |
var j = -1; while(++j < len) | |
{ | |
if(a[j] === 1) | |
break; | |
} | |
} | |
}, | |
function(n) | |
{ | |
var a = aL, len = a.length; | |
var i = n; while(i--) | |
{ | |
var j = -1; while(++j < len && a[j] !== 1) | |
; | |
} | |
} | |
], | |
1000 | |
); | |
/* | |
opera 10.62 | |
0: 258 ms | |
1: 263 ms | |
chrome7 | |
0: 344 ms | |
1: 355 ms | |
ie7 | |
0: 1342 ms | |
1: 1372 ms | |
ff3.6 | |
0: 354 ms | |
1: 362 ms | |
ff4b3 | |
0: 536 ms | |
1: 542 ms | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment