Test name | Executions per second |
---|---|
array[i] = i; | 306217.9 Ops/sec |
view.setFloat64(i, i) | 274843.6 Ops/sec |
array[i] = i; 2 | 305752.8 Ops/sec |
view.setFloat64(i, i) 2 | 273932.1 Ops/sec |
var buffer1 = new ArrayBuffer(1024 * Float64Array.BYTES_PER_ELEMENT);
var array = new Float64Array(buffer1);
var buffer2 = new ArrayBuffer(1024 * Float64Array.BYTES_PER_ELEMENT);
var view = new DataView(buffer2);
for (let i = 0; i < 1024; i += 1) {
if (i === 0) {
array[i] = 1;
} else {
array[i] = array[i-1] + i;;
}
}
for (let i = 0; i < 1024; i += 4) {
if (i === 0) {
view.setFloat64(i, 1);
} else {
view.setFloat64(i, view.getFloat64(i - 1) + i);
}
}
for (let i = 0; i < 1024; i += 1) {
if (i === 0) {
array[i] = 1;
} else {
array[i] = array[i-1] + i;;
}
}
for (let i = 0; i < 1024; i += 4) {
if (i === 0) {
view.setFloat64(i, 1);
} else {
view.setFloat64(i, view.getFloat64(i - 1) + i);
}
}