Array Performance (v139)

Revision 139 of this benchmark created by Jonatas Miguel on


Description

Manual array lookups vs. holey arrays.

Setup

var aI = 29938;
    var a = [];
    a[29938] = {id: 29938, name: 'name1'};
    a[32994] = {id: 32994, name: 'name2'};

    var oI = '29938';
    var o = {};
    o['29938'] = {id: 29938, name: 'name1'};
    o['32994'] = {id: 32994, name: 'name2'};

    var o2 = {};
    o2['_29938'] = {id: 29938, name: 'name1'};
    o2['_32994'] = {id: 32994, name: 'name2'};

    var o3 = {};
    for(var i = 29938; i <= 32994; i += 3056){
        o3['_' + i] = { id: i, name: 'name' + i };
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Holey Array by Index
var result = a[29938];
ready
Object by Key
var result = o['29938'];
ready
Object by Property
var result = o2._29938;
ready
Object by Property
var result = o3._29938;
ready
simple assignment
var result = aI;
ready
Just get aI
aI
ready

Revisions

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