Script Preparation code:
AخA
 
var arr = Array(10_000_000).fill(0);
Tests:
  • flatMap

     
    arr.flatMap(x => [x, x * 2]);
  • for loop

     
    const n = arr.length;
    const acc = new Array(n * 2);
    for (let i = 0; i < n; i++){
      const x = arr[i];
      acc[i * 2] = x;
      acc[i * 2 + 1] = x * 2;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    flatMap
    for loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Firefox 135 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
flatMap 4.1 Ops/sec
for loop 19.7 Ops/sec