Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
avgBy test
(version: 1)
Comparing performance of:
using function vs inline
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({ val1: Math.random() * 100, val2: Math.random() * 100 }); } const avgBy = (fn, arr) => arr.reduce((sum, obj) => sum + fn(obj), 0) / arr.length;
Tests:
using function
avgBy((obj) => obj.val1, data)
inline
avgBy(({val1}) => val1, data)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
using function
inline
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
using function
895K/s
inline
92K/s
View exact numbers
Test name
Executions per second
✓
using function
895,209 Ops/sec
inline
91,754 Ops/sec
Related benchmarks
Lodash sumBy vs map and reduce
Lodash maxBy vs Math.max & Map
Lodash sumBy vs reduce vs for loop
[2024] Lodash .sumBy vs. Reduce with / 1000
[2024] Lodash .sumBy vs. Reduce with / 10002
avgBy reduce vs map first
avgBy reduce vs inline
Comments
Confirm delete:
Do you really want to delete benchmark?