ES6 Map vs Object properties

JavaScript performance comparison

Revision 53 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var map = new Map();
  var obj1 = Object.create(null);
  var 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
Iterate null-prototype Object (for in)
var buf = '';
for (var key in obj1) {
    buf += obj1[key];
}
pending…
Iterate Object (for in)
var buf = '';
for (var key in obj2) {
    buf += obj2[key];
}
pending…
Iterate Map (for of keys)
var buf = '';
var keys = map.keys();

for (var key of keys) {
    buf += map.get(key);
}
pending…
Iterate Map (for of values)
var buf = '';
var vals = map.values();

for (var val of vals) {
    buf += val;
}
pending…
Iterate Map (forEach)
var buf = '';

map.forEach(function (key, val) {
    buf += val;
});
pending…
Iterate Map (for...of)
var buf = '';

for (var m of map) {
    buf += m[1];
}
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