Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash flatten vs reduce array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
flatten
27875.1 Ops/sec
reduce
1875.8 Ops/sec
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
Script Preparation code:
myList = []; for (let i = 0; i < 100; i++) { const arr = []; for (var n = 0; n < 100; n++) { arr.push({ ['key' + n]: n }); } myList.push(arr) }
Tests:
flatten
_.flatten(myList)
reduce
myList.reduce((acc, item) => { return [...acc, ...item]; }, [])