Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
testachunk3
(version: 0)
Comparing performance of:
1 vs 2 vs 3
Created:
5 years ago
by:
Guest
Jump to the latest result
Tests:
1
function chunkArraySlice(array, size) { let result = [] for (i = 0; i < array.length; i += size) { let chunk = array.slice(i, i + size) result.push(chunk) } return result } console.log(chunkArraySlice([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 2));
2
function chunkArray(myArray, chunk_size){ var results = []; while (myArray.length) { results.push(myArray.splice(0, chunk_size)); } return results; } console.log(chunkArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 2));
3
const chunkIt = (arr, size) => { let buckets = [] // Just create the buckets/chunks storage for (let i = 1; i <= Math.ceil(arr.length / size); i++) { buckets.push([]) } // Put in the buckets/storage by index access only for (let i = 0; i < arr.length; i++) { var arrIndex = Math.ceil((i + 1) / size) - 1 buckets[arrIndex].push(arr[i]) } return buckets; } console.log(chunkIt([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 2));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
1
2
3
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!
Related benchmarks:
Teste performance
delete vs undefined vs null - 4
TestJoas012
testtesttesttesttesttest
fdsfdsf
Comments
Confirm delete:
Do you really want to delete benchmark?