Benchmark Test: Object vs Map (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.6.9/core.min.js" integrity="sha256-+TULExmyD/NYybiq1jR6qIxiCQHqmjb3yGVZyKyIgso=" crossorigin="anonymous"></script>

Setup

  var object = {};
  var map = new Map();
  
  for (var i = 0; i < 1000000; i++) {
      var element = {
          key: ''+i,
          value: ''+Math.random()
      };
      object[element.key] = element;
      map.set(element.key, element);
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Object
var keyToFind = ''+(Math.floor(Math.random()*1000000));
var element = object[keyToFind];
ready
Map
var keyToFind = ''+(Math.floor(Math.random()*1000000));
var element = map.get(keyToFind);
ready

Revisions

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