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();
}
Tests:
  • DataView

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

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

     
    byte.set(data);
  • with Float64Array

     
    (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: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Chrome 112 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
DataView 158.2 Ops/sec
Uint8Array by byte 173.6 Ops/sec
Uint8Array with set 1018924.3 Ops/sec
with Float64Array 964288.8 Ops/sec