Chunk slice vs. Lodash chunk
Date tested:
one month ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Test name
Executions per second
Chunk by slice
15185290.0 Ops/sec
lodash chunk
157.2 Ops/sec
Benchmark definition (click to collapse):
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: 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; }
Tests:
Chunk by slice
chunkSlice(0,500)
lodash chunk
_.chunk(test,500)
Open this result on MeasureThat.net