HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
 
var data = Array(1000000).fill({ filtering: true, mapping: 42 });
Tests:
  • native lodash filter map

     
    data.filter(({ filtering }) => filtering).map(({ mapping }) => mapping)
  • Lazy Lodash filter-map

     
    _.map(_.filter(data, 'filtering'), 'mapping')
  • lodash reduce

     
    _.reduce(data, function(result, value, key) {
          if (value.filtering) {
            result.push(value.mapping)
          }
          return result;
      }, [])
  • native reduce

     
      data.reduce(function(result, value, key) {
          if (value.filtering) {
            result.push(value.mapping)
          }
          return result;
      }, [])
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    native lodash filter map
    Lazy Lodash filter-map
    lodash reduce
    native reduce

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0
Firefox 81 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
native lodash filter map 39.9 Ops/sec
Lazy Lodash filter-map 31.6 Ops/sec
lodash reduce 69.0 Ops/sec
native reduce 76.2 Ops/sec