Map vs Array

Benchmark created on


Setup

const serviceMap = {
	0: {},
	1: {},
	2: {},
	3: {},
	4: {},
	5: {},
	6: {},
	7: {},
	8: {},
	9: {},
}
const serviceArr = Object.keys(serviceMap).map((key) => ({ id: key }))

Test runner

Ready to run.

Testing in
TestOps/sec
Map
const s5 = serviceMap[5];
delete serviceMap[5];
ready
Array
const s5 = serviceArr.find((s) => s.id === 5);
serviceArr.splice(5, 1)
ready

Revisions

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