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4,4,4,4,4,4,4,4,2,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
Array.prototype.flatMap = function(f) {
  return [].concat(...this.map(f))
}
Tests:
  • lodash.flatMap

     
    _.flatMap(x,x => [x-1, x, x+1, x +2, x +2, x +2, x +2,x-1, x, x+1, x +2, x +2, x +2, x +2,x-1, x, x+1, x +2, x +2, x +2, x +2])
  • native

     
    x.flatMap(x => [x-1, x, x+1, x +2, x +2, x +2, x +2,x-1, x, x+1, x +2, x +2, x +2, x +2,x-1, x, x+1, x +2, x +2, x +2, x +2])
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash.flatMap
    native

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
Chrome 92 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
lodash.flatMap 11120.4 Ops/sec
native 9218.0 Ops/sec