HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
var arr = [];
for(var i = 0; i < 100; i++){
  arr.push({a: {b:1}});
}
Tests:
  • sumBy with function

     
    _.sumBy(arr, (item) => item.a.b)
  • sumBy with array

     
    _.sumBy(arr, ["a", "b"])
  • sumBy with string

     
    _.sumBy(arr, "a.b")
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    sumBy with function
    sumBy with array
    sumBy with string

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36
Chrome 80 on Windows
View result in a separate tab
Test name Executions per second
sumBy with function 155274.5 Ops/sec
sumBy with array 104002.8 Ops/sec
sumBy with string 15407.9 Ops/sec