Array/Set lookup performance

Benchmark created on


Setup

const array = Array.from({ length: 100000 }, () => Math.random())
const set = new Set(array)
const lookup = Array.from({ length: 1000 }, () => array[Math.random() * array.length | 0])

Test runner

Ready to run.

Testing in
TestOps/sec
Array includes
for (const item of lookup) {
	array.includes(item)
}
ready
Set.has (existing)
for (const item of lookup) {
	set.has(item)
}
ready
Set.has (newly created)
for (const item of lookup) {
	const set = new Set(array)
	set.has(item)
}
ready

Revisions

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