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

     
    data[Date.now()%data.length] = 43;
    for (let i; i < size; i++) {
        view.setUint8(i, data[i]);
    }
  • Uint8Array by byte

     
    data[Date.now()%data.length] = 43;
    for (let i; i < size; i++) {
        byte[i] = data[i];
    }
  • Uint8Array with set

     
    data[Date.now()%data.length] = 43;
    byte.set(data);
  • with Float64Array

     
    data[Date.now()%data.length] = 43;
    (new Float64Array(buf, 0, size/8))
          .set(new Float64Array(data.buffer, 0, size/8));
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
    with Float64Array

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 OPR/79.0.4143.72
Opera 79 on Windows
View result in a separate tab
Test name Executions per second
DataView 1840064.5 Ops/sec
Uint8Array by byte 1816404.4 Ops/sec
Uint8Array with set 360648.1 Ops/sec
with Float64Array 281877.3 Ops/sec