HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
x
 
var values = {a: 123, b: 234, c: 445, d: 23, e: 234, f:234, g: 345, h: 34, i: 43};
var forEachObjectKey = (object, toRun) => {
  const keys = Object.keys(object)
  let length = keys.length
  let index = -1
  while (length--) {
    index++
    toRun(keys[index], (object)[keys[index]])
  }
}
Tests:
  • lodash.forEach

     
    let count = 0;
    _.forEach(values, (v,i) => {
      if (i != null) {
        count+= i; 
      }
    })
  • custom foreach

     
    let count = 0
    forEachObjectKey(values, (key, value) => {
      if (value != null) {
        count += value
      }
    })
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash.forEach
    custom foreach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Linux
View result in a separate tab
Test name Executions per second
lodash.forEach 4001531.8 Ops/sec
custom foreach 9230919.0 Ops/sec