Map vs Obj

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Map
const map = new Map();
for (let i = 0; i < 1000; i++) {
	map.set("_" + i.toString(), i);
}
for (let i = 0; i < 1000; i++) {
	if (map.get("_" + i.toString()) !== i) { throw new Error(); }
}
ready
Obj
const map = {};
for (let i = 0; i < 1000; i++) {
	map["_" + i.toString()] = i;
}
for (let i = 0; i < 1000; i++) {
	if (map["_" + i.toString()] !== i) { throw new Error(); }
}
ready

Revisions

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