Filter on list of ids

Benchmark created on


Setup

const speakerCount = 250;
const speakers = Array(speakerCount).fill(0).map((v, i) => ({id: `speaker-${i+1}`, firstName: `Speaker ${i+1}`}))

Test runner

Ready to run.

Testing in
TestOps/sec
includes
const speakerIds = speakers.map(s => s.id);
const validSpeakers = speakers.filter(s => speakerIds.includes(s.id))
return validSpeakers.length
ready
keyBy
const speakersById = {};
for(const s of speakers) speakersById[s.id] = s;
const validSpeakers = speakers.filter(s => s.id in speakersById)
return validSpeakers.length
ready

Revisions

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