HTML Preparation code:
AخA
 
1
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.js"></script>
Script Preparation code:
 
var numbers = [10, 40, 230, 15, 18, 51, 1221, 24, 36, 28, 10, 6, 8, 7, 55, 89, 256, 102, 1, 23, 41, 38, 7, 2, 5, 9, 60]
var input = []
Array(1000).fill().forEach(_ => input.push(...numbers))
Tests:
  • native built-in filter

     
    input.filter(i => i > 10).map(x => x * x)
  • native logic for filter, map

     
    let result = []
    for (let x in input) {
      if (x > 10) result.push(x * x)
    }
  • using forEach

     
    let result = []
    input.forEach(x => {
      if (x > 10) result.push(x * x)
    })
  • lodash chain

     
    _.chain(input).filter(x => x > 10).map(x => x * x).value()
  • lodash not chain

     
    _.map(_.filter(input, x => x > 10), x => x * x)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    native built-in filter
    native logic for filter, map
    using forEach
    lodash chain
    lodash not chain

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/73.0
Firefox 73 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
native built-in filter 699.1 Ops/sec
native logic for filter, map 50.9 Ops/sec
using forEach 1825.8 Ops/sec
lodash chain 439.0 Ops/sec
lodash not chain 452.6 Ops/sec