Script Preparation code:
AخA
 
var test = [
  {
    id: 1,
    name: 1,
  },
  {
    id: 2,
    name: 12,
  },
  {
    id: 3,
    name: 13,
  },
  {
    id: 4,
    name: 14,
  },
  {
    id: 5,
    name: 15,
  },
  {
    id: 6,
    name: 16,
  }
]
Tests:
  • flatmap

     
    new Map(test.flatMap(c => {
      if (c.id < 3) {
        return []
      }
      return [[c.id, c]]
    }))
  • filter.map

     
    new Map(test.filter(c => {
      return c.id >= 3
    }).map(el => [el.id, el]))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    flatmap
    filter.map

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Chrome 93 on Linux
View result in a separate tab
Test name Executions per second
flatmap 773396.2 Ops/sec
filter.map 2795218.0 Ops/sec