Test name | Executions per second |
---|---|
Chunk by slice | 15185287.0 Ops/sec |
lodash chunk | 157.2 Ops/sec |
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
var test = Array.from({
length: 1000000
}, () => Math.random())
function chunkSlice(raw, chunkSize) {
const groups = [];
let i = 0;
while (i < raw.length) {
groups.push(raw.slice(i, (i += chunkSize)));
}
return groups;
}
chunkSlice(0,500)
_.chunk(test,500)