Map vs Set

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Map
for (let i = 0; i < 100; ++i) {
	const map = new Map()
	for (let i = 0; i < 100; ++i)
		map.set(i, i)
	for (const [key, value] of map)
		console.log(map.has(key))
}
ready
Set
for (let i = 0; i < 100; ++i) {
	const set = new Set()
	for (let i = 0; i < 100; ++i)
		set.add(i)
	for (const key of set)
		console.log(set.has(key))
}
ready

Revisions

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