Test name | Executions per second |
---|---|
soa | 1085.7 Ops/sec |
aos | 795.3 Ops/sec |
typed soa | 1055.9 Ops/sec |
var n = 3000;
var x = [], y =[], z =[];
var x32 = new Float32Array(n);
var y32 = new Float32Array(n);
var z32 = new Float32Array(n);
var vectors = [];
for(var i = 0; i < n; i++){
x[i] = Math.random()*100|0;
y[i] = Math.random()*100|0;
z[i] = Math.random()*100|0;
x32[i] = Math.random()*100|0;
y32[i] = Math.random()*100|0;
z32[i] = Math.random()*100|0;
vectors[i] = { x: x[i], y: y[i], z: z[i] };
}
var vector;
for (var i = 0; i < n; ++i) {
x[i] = 2 * x[i];
y[i] = 2 * y[i];
z[i] = 2 * z[i];
}
for (var i = 0; i < n; ++i) {
vector = vectors[i];
vector.x = 2 * vector.x;
vector.y = 2 * vector.y;
vector.z = 2 * vector.z;
}
for (var i = 0; i < n; ++i) {
x32[i] = 2 * x32[i];
y32[i] = 2 * y32[i];
z32[i] = 2 * z32[i];
}