Array vs Set

Benchmark created on


Setup

function generateTestData(size) {
  const data = [];
  for (let i = 0; i < size; i++) {
    data.push(i);
  }
  return data;
}

const size = 1000000;
const testData = generateTestData(size);
const testSet = new Set(testData);
const searchValue = size - 1;

testSet.has(searchValue);

Test runner

Ready to run.

Testing in
TestOps/sec
Array
testData.includes(searchValue);
ready
Set
testSet.has(searchValue);

ready

Revisions

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