Test name | Executions per second |
---|---|
DataView | 21108392.0 Ops/sec |
Uint8Array by byte | 21128900.0 Ops/sec |
Uint8Array with set | 1276160.0 Ops/sec |
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();
}
for (let i; i < size; i++) {
view.setUint8(i, data[i]);
}
for (let i; i < size; i++) {
byte[i] = data[i];
}
byte.set(data, 0);