Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash groupBy vs Array.reduce 500k
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash
29.6 Ops/sec
Native
31.6 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var max2 = 500000; var data = []; for (var i = 0; i <= max2; i++) { data.push({ id: i }); }
Tests:
Lodash
_.groupBy(data, ({ id }) => id)
Native
// Using reduce to mimic _.groupBy const grouped = data.reduce((acc, item) => { // Initialize an array for this id if it doesn't exist if (!acc[item.id]) acc[item.id] = []; // Push the item into the array for this id acc[item.id].push(item); return acc; }, {});