Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
soa vs aos
(version: 0)
As titled
Comparing performance of:
soa vs aos vs soa mark II
Created:
9 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
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;
Tests:
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]; }
aos
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 mark II
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]; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
soa
aos
soa mark II
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
19 days ago
)
User agent:
Mozilla/5.0 (Android 13; Mobile; rv:149.0) Gecko/149.0 Firefox/149.0
Browser/OS:
Firefox Mobile 149 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
soa
132.2 Ops/sec
aos
72.5 Ops/sec
soa mark II
110.1 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the test cases and explain what's being tested. **Benchmark Definition** The benchmark is comparing two approaches to scaling an array of numbers: 1. **Arrays of arrays (soa)**: The first approach, "soa", multiplies all three elements of a vector by 2 in each iteration. * Pros: Efficient use of memory and CPU cache, as only the modified elements need to be accessed. * Cons: May lead to slower performance due to the overhead of array indexing and bounds checking. 2. **Arrays (aos)**: The second approach, "aos", multiplies each element of the vector by 2 in each iteration. * Pros: Easier to understand and implement, as only the multiplication operation needs to be performed. * Cons: Requires more memory access and may lead to slower performance due to cache misses. **Library** The `Float32Array` is used to represent vectors. It's a typed array object that provides efficient storage for floating-point numbers. **Special JS Feature/Syntax** None of the benchmark tests use special JavaScript features or syntax, such as async/await, promises, or modern web APIs like Web Workers or Web Assembly. **Test Cases** The test cases are: 1. **soa**: Multiplies all three elements of a vector by 2 in each iteration. 2. **aos**: Multiplies each element of the vector by 2 in each iteration, and then multiplies all three elements of another copy of the same vector by 2 in each iteration. 3. **soa mark II**: Similar to "soa", but with a slight difference: it multiplies only two elements (x and y) instead of all three. **Performance** The benchmark results show that the "soa" approach is significantly faster than both "aos" approaches, with an execution rate of approximately 2.03 executions per second for "soa mark II" and 1.3798 executions per second for "aos". This suggests that the first approach is more efficient due to the reduced number of memory accesses. **Other Alternatives** Alternative approaches could include: * Using a library like NumJS or MathJS, which provide optimized implementations for linear algebra operations. * Using GPU acceleration using WebGL or WebGPU. * Using a different data structure, such as a matrix or a sparse matrix, that may be more efficient for certain types of scaling operations. Keep in mind that the performance results will depend on the specific use case and hardware configuration.
Related benchmarks:
soa vs aos
soa vs aos
soa vs aos
soa vs aos
Comments
Confirm delete:
Do you really want to delete benchmark?