Set (large array)

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Set
const arr = [];
for(let i = 0; i < 1000000; i++) {
	arr.push(i);
	arr.push(0);
}
arr.length === new Set(arr)

ready
Object
const arr = [];
const obj = {};
for(let i = 0; i < 1000000; i++) {
	arr.push(i);
	arr.push(0);
}
for(let num of arr) {
	if(num in obj) break;
	else obj[num] = true;
}
ready

Revisions

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