Tests:
  • slice() with map()

    x
     
    const length = 1000;
    const arrayBuffer = new ArrayBuffer(length);
    const array = new Uint8Array(arrayBuffer);
    for (let i = 0; i < length; i++) {
        array[i] = 22;
    }
    const dataView = new DataView(arrayBuffer);
    const transferArray = new Uint8Array(dataView);
    const resultArray = [...transferArray].map(Boolean);
  • slice() with for loop

     
    const length = 1000;
    const arrayBuffer = new ArrayBuffer(length);
    const array = new Uint8Array(arrayBuffer);
    for (let i = 0; i < length; i++) {
        array[i] = 22;
    }
    const dataView = new DataView(arrayBuffer);
    const transferArray = new Uint8Array(dataView);
    const resultArray = [...transferArray];
    for (let i = 0; i < length; i++) {
        resultArray[i] = Boolean(resultArray[i]);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    slice() with map()
    slice() with for loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 months ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Chrome 127 on Linux
View result in a separate tab
Test name Executions per second
slice() with map() 422438.9 Ops/sec
slice() with for loop 8035.1 Ops/sec