Map vs. Object Map (v3)

Revision 3 of this benchmark created on


Setup

const data = new Array(1000000)
	.fill(1)
	.map((item) => Math.floor(Math.random() * 1000000))
	
const map = new Map();

data.forEach((item) => { map.set(item, Math.random()); });
const set = new Set(data);

const obj = {}

data.forEach((item) => { obj[item] = Math.random(); });

data.sort();

Test runner

Ready to run.

Testing in
TestOps/sec
new Map()
data.forEach(e => map.get(e))
ready
Object map
data.forEach(e => obj[e])
ready
Set
data.forEach(e => set.has(e))
ready

Revisions

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