ES6 Map vs Object Get

JavaScript performance comparison

Revision 227 of this test case created by Eric Anderson

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var map = new Map();
  var obj = {};
  
  for (var i=2_000; i>0 ; i--) {
     map.set(`key${i}`, Math.random());
     obj[`key${i}`] = Math.random();
  }

};
</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.get
let temp = map.get(`key${i}`);
pending…
obj[key]
let temp = obj[`key${i}`];
pending…

Revisions

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

0 Comments