ES6 Map vs Object properties (v49)

Revision 49 of this benchmark created on


Description

Compare native Map implementation vs an object without hasOwnProperty as a hash map.

Setup

var map = new Map(),
        obj1 = Object.create(null),
        obj2 = {};
    
    for (var i=0; i < 1000; i++) {
       var key = Math.random(), val = Math.random();
       
       map.set(key,val);
       obj1[key] = val;
       obj2[key] = val;
    }
       map.set('0',1);
       obj1['0'] = 1;
       obj2['0'] = 1;

Test runner

Ready to run.

Testing in
TestOps/sec
map.set(key,val)
obj1['0']
ready
obj[key] = val;
obj2['0']
ready
Iterate Map (for of)
map['0']
ready
Iterate Map (for)
val = map.values();

for ( key in val ) {
    key;
}
ready
Iterate Object
 
ready

Revisions

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