Multiple arrays vs One large array of objects

JavaScript performance comparison

Test case created by Pushkar DK

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
One array with large objects
var a = [
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}, 
{a: 1, b: 2, c: 3, d: 4}
];

for(var i = 0;i < a.length;i++) {
    console.log(a[i].a);
    console.log(a[i].b);
}
pending…
Multiple arrays
var x = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
y = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];


for(var i = 0;i < x.length;i++) {
    console.log(x[i]);
    console.log(y[i]);
}
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments