Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
sumby with reduce vs by mapping first
(version: 1)
Comparing performance of:
map first vs just reduce
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const arr = Array.from({ length: 100000 }, () => ({ rand: Math.random() }));
Tests:
map first
var b = arr.map((obj) => obj.rand).reduce((acc, curr) => acc + curr, 0);
just reduce
var b = arr.reduce((acc, curr) => acc + curr.rand, 0)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
map first
just reduce
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/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
map first
315.9 Ops/sec
just reduce
1035.9 Ops/sec
Related benchmarks:
Test: reduce vs for
Map reduce vs sumBy
flatMap + reduce vs reduce + reduce
flat vs flatMap vs reduce
Get max from an array of numbers (Math.max vs. iteration) V3
flatMap vs reduce vs filter.map
Math.min vs reduce
flatMap vs reduce vs filter.map v2
flatMap vs reduce filtering performance
Comments
Confirm delete:
Do you really want to delete benchmark?