_.sumBy value vs map and reduce vs _.sumBy with map vs sum with for of loop vs sum with for loopFastest: sum with for of loop (8.7x faster)
12,195 ops/sec
3,152 ops/sec
2,064 ops/sec
1,754 ops/sec
1,405 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| _.sumBy value | |
| map and reduce | |
| _.sumBy with map | |
| sum with for of loop | |
| sum with for loop |
| Test name | Executions per second |
|---|---|
| ✓ sum with for of loop | 7,607 Ops/sec |
| sum with for loop | 3,662 Ops/sec |
| _.sumBy value | 2,282 Ops/sec |
| _.sumBy with map | 1,404 Ops/sec |
| map and reduce | 1,372 Ops/sec |