Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash.js vs Javascript (meanBy) 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
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:
Chrome 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Native
114.2 Ops/sec
Lodash
92.6 Ops/sec
forLoopMeanBy
581.4 Ops/sec
forOfMeanBy
678.9 Ops/sec
whileMeanBy
583.8 Ops/sec
forEachMeanBy
261.2 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
const data = Array.from({ length: 1_000_000 }, (_, i) => ({ value: i % 100 })); function nativeMeanBy(array, key) { const sum = array.reduce((acc, obj) => acc + obj[key], 0); return sum / array.length; } function lodashMeanBy(array, key) { return _.meanBy(array, key); } function forLoopMeanBy(array, key) { let sum = 0; for (let i = 0; i < array.length; i++) { sum += array[i][key]; } return sum / array.length; } function forOfMeanBy(array, key) { let sum = 0; for (const obj of array) { sum += obj[key]; } return sum / array.length; } function whileMeanBy(array, key) { let sum = 0; let i = 0; const len = array.length; while (i < len) { sum += array[i++][key]; } return sum / len; } function forEachMeanBy(array, key) { let sum = 0; array.forEach(obj => sum += obj[key]); return sum / array.length; }
Tests:
Native
nativeMeanBy(data, 'value')
Lodash
lodashMeanBy(data, 'value')
forLoopMeanBy
forLoopMeanBy(data, 'value')
forOfMeanBy
forOfMeanBy(data, 'value')
whileMeanBy
whileMeanBy(data, 'value')
forEachMeanBy
forEachMeanBy(data, 'value')