Iterator vs Array

Benchmark created on


Setup

let sett = new Set();
for (let i = 0; i < 100_000; i++) {
	sett.add(`num_${i}`);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Find iter
let res

for (let el of sett.values()) {
	if (el === "num_10045") {
		res = el
		break
	}
}

console.log(res)
ready
Find arr
const res = Array.from(sett.values()).some(el => el === "num_10045")
ready

Revisions

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