Run details:
Mozilla/5.0 (Linux; Android 11; GM1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36
Chrome Mobile 103
Android
Mobile
2 years ago
Test name Executions per second
DataView 2157946.8 Ops/sec
Uint8Array by byte 1314296.2 Ops/sec
Uint8Array with set 529723.7 Ops/sec
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]);
    }
  • Uint8Array by byte

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

     
    byte.set(data, 0);