array creation

Benchmark created on


Setup

const generateData = (size) => Array.from({length: size}, (_, idx) => idx + 1)
const generateData2 = (size) => {
  let index = 0
  return Array(size)
    .fill(0)
    .flatMap(val => {
      index += 1
      return [val + index]
    })
}

const generateData3 = (size) => Array(size)
    .fill(0)
    .map((_, idx) => idx + 1)

Test runner

Ready to run.

Testing in
TestOps/sec
inline
generateData(50_000)
ready
flatmap
generateData2(50_000)
ready
map
generateData3(50_000)
ready

Revisions

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