Test name | Executions per second |
---|---|
soa | 92.0 Ops/sec |
aos | 6.3 Ops/sec |
soa mark II | 95.4 Ops/sec |
var N = 1000000;
var x = [], y = [], z = [];
var xt = new Float32Array(1000000);
var yt = new Float32Array(1000000);
var zt = new Float32Array(1000000);
var vectors = [];
for(var i = 0; i < N; i++){
x[i] = Math.random();
y[i] = Math.random();
z[i] = Math.random();
xt[i] = x[i];
yt[i] = y[i];
zt[i] = z[i];
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;
}
for (var i = 0, li=x.length; i < li; ++i) {
x[i] = 2 * x[i];
}
for (var i = 0, li=y.length; i < li; ++i) {
y[i] = 2 * y[i];
}
for (var i = 0, li=z.length; i < li; ++i) {
z[i] = 2 * z[i];
}