Benchmark Test: Object vs Map

Benchmark created on


Description

LKSD Code Test

Setup

  var object = {};
  var map = new Map();
  
  for (var i = 0; i < 100000; 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()*100000));
var element = object[keyToFind];
ready
Map
var keyToFind = ''+(Math.floor(Math.random()*100000));
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.