Tests:
  • chunks_yield

    AخA
     
    function chunks_yield(array, size) {
        function* chunk(arr, n) {
            for (let i = 0; i < arr.length; i += n) {
                yield arr.slice(i, i + n);
            }
        }
        return [...chunk(array, size)];
    }
  • chunks_perf

    x
     
    function chunks(arr, n) {
        return arr.reduce((chunk, val) => {
            if (chunk[chunk.length - 1].length === n)
                chunk.push([]);
            chunk[chunk.length - 1].push(val);
            return chunk;
        }, [
            []
        ]);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    chunks_yield
    chunks_perf

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 11 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Chrome 117 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
chunks_yield 1004751744.0 Ops/sec
chunks_perf 1009620288.0 Ops/sec