ES6 Map vs Object properties

JavaScript performance comparison

Revision 49 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  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;

};
</script>

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
map.set(key,val)
obj1['0']
pending…
obj[key] = val;
obj2['0']
pending…
Iterate Map (for of)
map['0']
pending…
Iterate Map (for)
val = map.values();

for ( key in val ) {
    key;
}
pending…
Iterate Object
pending…

Compare results of other browsers

Revisions

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

0 Comments