Script Preparation code:
AخA
 
var length = 1000000;
var arr = Array.from(Array(length).fill(0),(n, index)=>({date: Math.round(Math.random()*length), internalId: index }) );
Tests:
  • filter + map

     
     const ids = arr.filter((item) => true).map(item => item.internalId);
  • flatMap

     
     const ids = arr.flatMap((item) => item.date > 1 ? item.internalId : []);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    filter + map
    flatMap

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Chrome 104 on Linux
View result in a separate tab
Test name Executions per second
filter + map 34.6 Ops/sec
flatMap 11.7 Ops/sec