test

Benchmark created on


Setup

const data = [];
for (let i = 0; i < 1000; i++) {
  data.push({
    id: i,
    value: Math.random() * 100,
    active: i % 3 === 0
  });
}

Test runner

Ready to run.

Testing in
TestOps/sec
filtermap
data.filter(item => item.active).map(item => item.value * 2);
ready
forof
const resultForOf = [];
for (const item of data) {
  if (item.active) {
    resultForOf.push(item.value * 2);
  }
}
ready

Revisions

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