Test name | Executions per second |
---|---|
DataView | 59446236.0 Ops/sec |
Uint8Array by byte | 61531012.0 Ops/sec |
Uint8Array with set | 824513.2 Ops/sec |
with Float64Array | 804934.2 Ops/sec |
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();
}
for (let i; i < size; i++) {
view.setUint8(i, data[i]);
}
for (let i; i < size; i++) {
byte[i] = data[i];
}
byte.set(data);
(new Float64Array(buf, 0, size/8))
.set(new Float64Array(data.buffer, 0, size/8));