Map vs Set creation

Benchmark created on


Setup

function getRandomInt() {
	return ~~(Math.random() * 100)
}

Test runner

Ready to run.

Testing in
TestOps/sec
Map creation
const map = new Map();
for (let i = 0; i < 10_000; i++) {
	map.set(getRandomInt(), true);
}
ready
Set creation
const set = new Set();
for (let i = 0; i < 10_000; i++) {
	set.add(getRandomInt());
}
ready

Revisions

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