Test name | Executions per second |
---|---|
soa | 629.7 Ops/sec |
aos | 257.1 Ops/sec |
var x = new Float32Array(1000000),
y = new Float32Array(1000000),
z = new Float32Array(1000000);
var vectors = [];
for (var i = 0; i < 1000000; i++) {
x[i] = Math.random() * 100;
y[i] = Math.random() * 100;
z[i] = Math.random() * 100;
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;
}