Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
matrix test
(version: 0)
test patterns for matrix perf
Comparing performance of:
vec3 Arr vs vec3 obj
Created:
9 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function addObj(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; return out; }; function addArr(out, oo, a, b, ao,bo) { out[0+oo] = a[0+ao] + b[0+bo]; out[1+oo] = a[1+ao] + b[1+bo]; out[2+oo] = a[2+ao] + b[2+bo]; };
Tests:
vec3 Arr
var A = new Float32Array(300); var B = new Float32Array(300); var O = new Float32Array(300); for (var i = 0;i < 1000;++i) { for (var j=0;j< 100;++j) { addArr(O,j*3,A,B,j*3,j*3); } }
vec3 obj
var A = []; var B = []; var O = []; for (var x=0;x<100;++x) { A.push(new Float32Array(3)); B.push(new Float32Array(3)); O.push(new Float32Array(3)); } for (var i = 0;i < 1000;++i) { for (var j=0;j< 100;++j) { addObj(O[j],A[j],B[j]); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
vec3 Arr
vec3 obj
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser/OS:
Chrome 119 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
vec3 Arr
291.1 Ops/sec
vec3 obj
273.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON and explain what is tested, compared, and other considerations. **Benchmark Definition** The benchmark definition represents a JavaScript function that performs a specific task. In this case, there are two test cases: 1. `vec3 Arr`: This test case uses arrays (`Float32Array`) to store data. The `addArr` function takes four arguments: `out`, `oo`, `a`, and `b`. It adds corresponding elements of the input arrays `a` and `b` to the output array `out`. 2. `vec3 obj`: This test case uses objects (`Float32Array`) as the data structure. The `addObj` function takes three arguments: `out`, `a`, and `b`. It adds corresponding properties of the input objects `a` and `b` to the output object `out`. **Options Compared** The benchmark compares two options: 1. **Array-based approach (`vec3 Arr`)**: This approach uses arrays to store data, which are created using `Float32Array`. The `addArr` function adds elements of the input arrays to the output array. 2. **Object-based approach (`vec3 obj`)**: This approach uses objects as the data structure, where each object has three properties (e.g., `x`, `y`, and `z`). The `addObj` function adds corresponding properties of the input objects to the output object. **Pros and Cons** Here are some pros and cons of each approach: **Array-based approach (`vec3 Arr`)** Pros: * Faster access and manipulation of data using array operations. * Less memory overhead compared to objects, especially for large datasets. Cons: * Limited flexibility in terms of data structure and organization. * May not be suitable for applications that require complex relationships between data elements. **Object-based approach (`vec3 obj`)** Pros: * More flexible and expressive way to represent complex data structures. * Allows for easier manipulation and analysis of data properties. Cons: * Slower access and manipulation of data compared to array operations. * Higher memory overhead due to the creation of objects. **Other Considerations** * **Memory allocation**: Both approaches require allocating memory for the output arrays or objects. However, object-based approach may lead to more memory allocation and deallocation due to the dynamic nature of object creation. * **Cache locality**: Array-based approach tends to improve cache locality, which can lead to better performance in practice. * **Data type overhead**: Using `Float32Array` instead of native number types (e.g., `number`) may incur a small overhead. **Libraries and Special JS Features** In the provided benchmark definition, there is no mention of any specific libraries or special JavaScript features. However, it's worth noting that: * `Float32Array` is a typed array class in JavaScript, which provides efficient memory management for floating-point numbers. * The use of `push` and `push`-style methods (e.g., `A.push(new Float32Array(3))`) suggests using modern JavaScript features. **Alternatives** Other alternatives to compare the performance of array-based and object-based approaches might include: * Using other data structures, such as matrices or graphs. * Implementing different algorithms for adding elements to arrays or objects (e.g., using loops instead of built-in functions). * Using a different programming language or virtual machine for execution. It's worth noting that the specific choices made in this benchmark definition (using arrays and `Float32Array`) may be influenced by factors such as: * The target platform and browser. * The performance requirements of the application. * The availability of computational resources.
Related benchmarks:
matrix test
matrix test
matrix test
mat4 array caching
Comments
Confirm delete:
Do you really want to delete benchmark?