Skip to content

Instantly share code, notes, and snippets.

@bga
Created April 1, 2010 16:54
Show Gist options
  • Save bga/352071 to your computer and use it in GitHub Desktop.
Save bga/352071 to your computer and use it in GitHub Desktop.
var i,n=3000, j;
var a=document.getElementsByTagName('li'), m = a.length, v;
for(j = 0 ; j < m ; ++j)
a[j].b = {};
console.time("1");
for(i = 0 ; i < n ; ++i)
for(j = 0 ; j < m ; ++j)
(v = a[j]).x = 1, v.y = 1, v.z = v.x, v.g = v.x + v.y + v.z;
console.timeEnd("1");
console.time("2");
for(i = 0 ; i < n ; ++i)
for(j = 0 ; j < m ; ++j)
(v = a[j].b).x = 1, v.y = 1, v.z = v.x, v.g = v.x + v.y + v.z;
console.timeEnd("2");
/*
ff 3.6 n = 3000
2: 2694
1: 2792
1: 2877
2: 2552
chrome 4 n = 3000
1: 2916
2: 2845
2: 2952
1: 2759
opera 10.51 n = 3000
2: 1736
1: 1614
1: 1664
2: 1649
ie n = 500
2: 1191
1: 2334
1: 2424
2: 1101
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment