Native map vs Katamari map

Benchmark created on


Setup

const map = (xs, f) => {
  const len = xs.length;
  const r = new Array(len);
  for (let i = 0; i < len; i++) {
    const x = xs[i];
    r[i] = f(x, i);
  }
  return r;
};

const data = Array.from({ length: 30000 }, (_, i) => i + 1);

Test runner

Ready to run.

Testing in
TestOps/sec
Native map
data.map((a) => a + 1)
ready
Katamari map
map(data, (a) => a + 1)
ready

Revisions

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