Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash chunk vs JS reduce
(version: 1)
Comparing performance of:
Lodash vs JS vs Chunk slice
Created:
11 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var arr = Array.from({ length: 100000 }, () => Math.random())
Tests:
Lodash
const groups = _.chunk(arr,5000)
JS
const chunk = (input, size) => { return input.reduce((arr, item, idx) => { return idx % size === 0 ? [...arr, [item]] : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]]; }, []); }; chunk(arr,5000);
Chunk slice
function chunk(arr, chunkSize) { if (chunkSize <= 0) { throw new Error("Chunk size has to be greater than 0."); } const chunks = []; for (let i = 0; i < arr.length; i = i + chunkSize) { chunks.push(arr.slice(i, i + chunkSize)); } return chunks; } chunk(arr,5000);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash
JS
Chunk slice
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser/OS:
Firefox 139 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
3716.0 Ops/sec
JS
1.0 Ops/sec
Chunk slice
54851.6 Ops/sec
Related benchmarks:
wefgsdgsdg
Chunk - lodash vs javascripto
lodash chunk
Chunk: lodash vs you-dont-need vs youmightnotneed vs ...
Lodash chunk vs JS
Lodash chunk vs JS 2
lodash chunk vs native
Lodash Chunk vs Native Reduce
Chunk - lodash vs javascript vs for loop vs reduce
Comments
Confirm delete:
Do you really want to delete benchmark?