Script Preparation code:
x
 
var size = 0xFF;
var buf = new ArrayBuffer(size);
var view = new DataView(buf);
var byte = new Uint8Array(buf);
var data = [];
for (let i = 0; i < size; i++) {
    data[i] = 100*Math.random();
}
Tests:
  • DataView

     
    for (let i; i < size; i++) {
        view.setUint8(i, data[i]);
    }
    const results = []
    for (let i; i < size; i++) {
        results.push(view.getUint8(i, data[i]));
    }
  • Uint8Array by byte

     
    for (let i; i < size; i++) {
        byte[i] = data[i];
    }
    const results = [];
    for (let i; i < size; i++) {
        results.push(byte[i]);
    }
  • Uint8Array with set

     
    byte.set(data, 0);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    DataView
    Uint8Array by byte
    Uint8Array with set

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Chrome 130 on Windows
View result in a separate tab
Test name Executions per second
DataView 6526921.5 Ops/sec
Uint8Array by byte 6428717.5 Ops/sec
Uint8Array with set 1978330.1 Ops/sec