Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Slice vs chunk
(version: 0)
Comparing performance of:
Lodash vs slice vs push vs you might not need
Created:
one year 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 test = Array.from({ length: 100000 }, () => Math.random()) function createGroupedArray(arr, chunkSize) { const groups = []; let i = 0; while (i < arr.length) { groups.push(arr.slice(i, i += chunkSize)); } return groups; }; function array_to_chunks(data, size){ let chunks = [] let d = data.slice() while (d.length >= size) chunks.push(d.splice(0, size)) return chunks } const chunk = (arr, chunkSize = 1, cache = []) => { const tmp = [...arr] if (chunkSize <= 0) return cache while (tmp.length) cache.push(tmp.splice(0, chunkSize)) return cache }
Tests:
Lodash
_.chunk(test,5000)
slice
createGroupedArray(test,5000)
push
array_to_chunks(test,5000)
you might not need
chunk(test,5000)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Lodash
slice
push
you might not need
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?