Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
avgBy reduce vs map first
(version: 1)
Comparing performance of:
reduce vs map then reduce
Created:
one year ago
by:
Guest
Go to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
var data = []; for (let i = 0; i < 1000; i++) { data.push({ value: Math.random() * 100 }); } function getValue(obj) { return obj.value; }
Tests:
reduce
data.reduce((sum, obj) => sum + getValue(obj), 0) / data.length;
map then reduce
data.map(getValue).reduce((sum, val) => sum + val, 0) / data.length;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
reduce
map then 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
reduce
893K/s
map then reduce
141K/s
View exact numbers
Test name
Executions per second
✓
reduce
893,110 Ops/sec
map then reduce
140,538 Ops/sec
Related benchmarks
Lodash sumBy vs map and reduce
GroupBy vs Reduce
Lodash sumBy (value and map) vs reduce
Lodash meanBy vs JS (with small and large size)
Lodash meanBy vs js vs reduce lodash
avgBy reduce vs inline
avgBy test
Comments
Confirm delete:
Do you really want to delete benchmark?