Small sets or arrays?

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
array
let y = false;
for(let i = 0; i < 1000000; ++i) {
	let x = [0, 1, 2, 3, 4]
	for (let j = 0; j < 1000; j++ ) {
		y = y || x.includes(4);
	}
}
console.log(y)
ready
set
let y = false;
for(let i = 0; i < 1000000; ++i) {
	let x = new Set([0, 1, 2, 3, 4])
	for (let j = 0; j < 1000; j++ ) {
		y = y || x.has(4);
	}
}
console.log(y)
ready

Revisions

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