ES6 Map vs Object properties

JavaScript performance comparison

Revision 48 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;
  }

};
</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)
for ( key in obj1 ) {
    obj1[key];
}
pending…
obj[key] = val;
for ( key in obj2 ) {
    obj2[key];
}
pending…
Iterate Map (for of)
val = map.keys();

for ( key in val ) {
    map[key];
}
pending…
Iterate Map (for)
val = map.values();

for ( key in val ) {
    key;
}
pending…
Iterate Object
i = map.entries();

for ( var [key,val] of i ) {
    val;
}
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