Map vs. Object Map

Benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
new Map()
const map = new Map();

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

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

Revisions

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