Map vs. Object Map (v4)

Revision 4 of this benchmark created on


Setup

const data = new Array(100000)
	.fill(1)
	.map((item) => Math.floor(Math.random() * 100000).toString())
	
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.