Script Preparation code:
x
 
var N = 1000000
var x = new Float32Array(N);
var y = new Float32Array(N);
var z = new Float32Array(N);
var interlaced = new Float32Array(3*N);
var vectors = [];
for (var i = 0, li=x.length; i < li; ++i) {
    x[i] = Math.random();
    y[i] = Math.random();
    z[i] = Math.random();
    vectors.push( {x:Math.random(), y:Math.random(), z:Math.random()} );
}
for (var i = 0, li=interlaced.length; i < li; ++i) {
    interlaced[i] = Math.random();
}
Tests:
  • AoS

     
    var vector;
    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;
    }
  • SoA

     
    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];
    }
  • SoA - one component per loop

     
    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];
    }
  • Interlaced Array - no loop unrolling

     
    for (var i = 0, li=interlaced.length; i < li; ++i) {
        interlaced[i] = 2*interlaced[i];
    }
  • Interlaced Array - with loop unrolling

     
    for (var i = 0, li=interlaced.length; i < li; i+=3) {
        interlaced[i] = 2*interlaced[i];
        interlaced[i+1] = 2*interlaced[i+1];
        interlaced[i+2] = 2*interlaced[i+2];
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    AoS
    SoA
    SoA - one component per loop
    Interlaced Array - no loop unrolling
    Interlaced Array - with loop unrolling

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0
Firefox 114 on Linux
View result in a separate tab
Test name Executions per second
AoS 218.4 Ops/sec
SoA 422.8 Ops/sec
SoA - one component per loop 419.0 Ops/sec
Interlaced Array - no loop unrolling 279.0 Ops/sec
Interlaced Array - with loop unrolling 382.5 Ops/sec