Script Preparation code:
AخA
 
var arr = Array(10_000).fill(1)
Tests:
  • Reduce concat

     
    arr.reduce((acc, x, index) => acc.concat(x, index % 2 ? x : []), [])
  • FlatMap

     
    arr.flatMap((x, index) => [x, index % 2 && x]).filter(Boolean)
  • Reduce push

     
    arr.reduce((acc, x, index) => { acc.push(x); if(index % 2) { acc.push(x) } return acc; }, [])
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Reduce concat
    FlatMap
    Reduce push

    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_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Reduce concat 8.6 Ops/sec
FlatMap 3188.7 Ops/sec
Reduce push 35196.3 Ops/sec