split vs includes

Benchmark created on


Setup

// Generate an array of 10,000 keys
const keys = Array.from({ length: 10000 }, (_, i) => {
  if (i % 10 === 0) {
    return `Asset Mix.${i}`;
  } else {
    return `Other Mix.${i}`;
  }
});

Test runner

Ready to run.

Testing in
TestOps/sec
split


// Perform the split method test
console.time("split");
keys.forEach(key => {
  const isAssetMix = key.split(".")[0] === "Asset Mix";
});
console.timeEnd("split");

ready
includes

// Perform the includes method test
console.time("includes");
keys.forEach(key => {
  const isAssetMix = key.includes("Asset Mix");
});
console.timeEnd("includes");
ready

Revisions

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