Set vs Array.includes

Benchmark created on


Setup

const list = Array(100000).fill('').map(() => `${Math.random()}`);
const set = new Set(list);

const firstEl = list[0];
const middleEl = list[50000];
const lastEl = list[99999];

Test runner

Ready to run.

Testing in WebKit 537.36 / undefined
TestOps/sec
Set first element
set.has(firstEl);
ready
Set middle element
set.has(middleEl);
ready
Set last element
set.has(lastEl);
ready
Array.includes first element
list.includes(firstEl);
ready
Array.includes middle element
list.includes(middleEl);
ready
Array.includes last element
list.includes(lastEl);
ready

Revisions

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