Skip to content

Instantly share code, notes, and snippets.

@bga
Created October 1, 2010 18:14
Show Gist options
  • Save bga/606615 to your computer and use it in GitHub Desktop.
Save bga/606615 to your computer and use it in GitHub Desktop.
/*
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