Test name | Executions per second |
---|---|
soa | 1.5 Ops/sec |
aos | 0.6 Ops/sec |
soa mark II | 1.0 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;
y[i] *= 2;
z[i] *= 2;
}
for (var i = 0, li=vectors.length; i < li; ++i) {
vector = vectors[i];
vector.x *= 2;
vector.y *= 2;
vector.z *= 2;
}
for (var i = 0, li=xt.length; i < li; ++i) {
xt[i] *= 2;
}
for (var i = 0, li=yt.length; i < li; ++i) {
yt[i] *= 2;
}
for (var i = 0, li=zt.length; i < li; ++i) {
zt[i] *= 2;
}