array vs object (v20)

Revision 20 of this benchmark created on


Setup

var a=["x","y","z"];
    
    var oN={x:null,y:null,z:null};
    var o={x:0,y:0,z:0};
    
    var XYZ={};
    XYZ["x"]=10.2235;
    XYZ["y"]=-52.9564;
    XYZ["z"]=10.5864;

Teardown


    var ra=Math.random();
  

Test runner

Ready to run.

Testing in
TestOps/sec
array
for(var i in a)
{
    var xyz=a[i];
    for(var j=0;j<20;j++)
    {
        XYZ[xyz]+=ra;
    }
}
ready
object
for(var xyz in o)
{
    for(var j=0;j<20;j++)
    {
        XYZ[xyz]+=ra;
    }
}
ready
object 2
for(var xyz in oN)
{
    for(var j=0;j<20;j++)
    {
        XYZ[xyz]+=ra;
    }
}
ready

Revisions

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