Map vs object

Benchmark created on


Setup

var obj = {
	a: 1,
	b: 2,
	c: 3
};

var mapObj = new Map();
mapObj.set('a', 1);
mapObj.set('b', 2);
mapObj.set('c', 3);

var x = {};
var y = {};
var z = {};
var mapObj2 = new Map();
mapObj2.set(x, 1);
mapObj2.set(y, 2);
mapObj2.set(z, 3);

var results = [];

Teardown

var results = [];

Test runner

Ready to run.

Testing in
TestOps/sec
Obj access
results.push(obj.a);
results.push(obj.b);
results.push(obj.c);
ready
Map access
results.push(mapObj.get('a'));
results.push(mapObj.get('b'));
results.push(mapObj.get('c'));
ready
Map non-key access
results.push(mapObj2.get(x));
results.push(mapObj2.get(y));
results.push(mapObj2.get(z));
ready

Revisions

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