set vs array

Benchmark created on


Setup

const summaryRecs = [{id:1}, {id:2}];

Test runner

Ready to run.

Testing in
TestOps/sec
Array
let y = 0;
while (y < 10_000) {
	let test = summaryRecs.some(it => it.id === y);
	y++;
} 
ready
Set
const summarySet = new Set(summaryRecs.map(it => it.id));
let y = 0;
while (y < 10_000) {
	let test = summarySet.has(y);
	y++;
} 
ready

Revisions

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