Script Preparation code:
AخA
 
var arr = Array(10_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: 5 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Chrome 130 on Windows
View result in a separate tab
Test name Executions per second
flatMap 3630.4 Ops/sec
for loop 2351.3 Ops/sec