ES6 Map vs Object Get

JavaScript performance comparison

Revision 230 of this test case created by Eric Anderson

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var map = new Map();
  var obj = {};
  
  for (var i=5; 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
obj[key]
let temp = obj[`key0`];
pending…
map.get
let temp = map.get(`key0`);
pending…
obj.key0
let temp = obj.key0
pending…

Revisions

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

0 Comments