Map vs Object for lookup

Benchmark published by System on

Description

Compare looking up values in a Map vs a plain Object.

Setup

const size = 10000;
const map = new Map();
const obj = {};
for (let i = 0; i < size; i++) {
  map.set('key' + i, i);
  obj['key' + i] = i;
}
const target = 'key' + (size / 2);

Test Runner

Initializing...

Testing in
Test CaseOps/sec
Map.get
map.get(target);
ready
Object lookup
obj[target];
ready

Revisions

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

Revision 1
publishedby Systemon