Test name | Executions per second |
---|---|
soa | 6.9 Ops/sec |
aos | 4.7 Ops/sec |
var x = [], y =[], z =[];
var vectors = [];
for(var i = 0; i < 1000000; i++){
x[i] = Math.random()*100|0;
y[i] = Math.random()*100|0;
z[i] = Math.random()*100|0;
vectors[i] = { x: x[i], y: y[i], z: z[i] };
}
var vector;
for (var i = 0, li=x.length; i < li; ++i) {
x[i] = 2 * x[i];
y[i] = 2 * y[i];
z[i] = 2 * z[i];
}
for (var i = 0, li=vectors.length; i < li; ++i) {
vector = vectors[i];
vector.x = 2 * vector.x;
vector.y = 2 * vector.y;
vector.z = 2 * vector.z;
}