Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash's Sum vs Reduce vs For-Loop
(version: 2)
Comparing performance of:
lodash sum vs javascript reduce vs javascript for loop
Created:
2 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
window.tabs = Array.from({ length: 1e7 }, () => Math.floor(Math.random() * 40));
Tests:
lodash sum
const total = _.sum(window.tabs);
javascript reduce
const total = window.tabs.reduce((a,b) => a+b);
javascript for loop
let total = 0; for (const tab of window.tabs) { total += tab; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
lodash sum
javascript reduce
javascript for loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash sum
24.1 Ops/sec
javascript reduce
13.6 Ops/sec
javascript for loop
12.8 Ops/sec
Related benchmarks:
Sum vs Reduce
Sum vs Reduce comparision
lodash reduce vs array reduce
For in vs Reduce
Comments
Confirm delete:
Do you really want to delete benchmark?