Script Preparation code:
AخA
 
var arr = Array(10_000).map((_, i) => i)
Tests:
  • flatMap

     
    const out = arr.flatMap(x => x % 3 === 0 ? [x, x]: []);
  • forEach with conditional push

     
    const out = [];
    arr.forEach(x => (x % 3 === 0) && out.push(x));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    flatMap
    forEach with conditional push

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
flatMap 9884.0 Ops/sec
forEach with conditional push 52939.0 Ops/sec