Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Push to: array vs float32array performance test 2
(version: 0)
Comparing performance of:
create arrays vs create typed arrays vs create typed arrays in typed array
Created:
one year ago
by:
Registered User
Jump to the latest result
Tests:
create arrays
const a = []; for (let i = 0; i < 10_000; i++) { a.push([]); }
create typed arrays
const a = []; for (let i = 0; i < 10_000; i++) { a.push(new Float32Array()); }
create typed arrays in typed array
const a = new Float32Array(10_000); for (let i = 0; i < 10_000; i++) { a[i] = new Float32Array(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
create arrays
create typed arrays
create typed arrays in typed array
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser/OS:
Firefox 128 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
create arrays
9357.8 Ops/sec
create typed arrays
2153.1 Ops/sec
create typed arrays in typed array
338.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'd be happy to explain what's being tested in the provided benchmark. The benchmark is comparing the performance of three different approaches when creating arrays and typed arrays in JavaScript: 1. **Pushing untyped arrays**: The first test case creates an array `a` and then pushes new empty arrays into it using the `push()` method. This approach creates a new array object on each push operation. 2. **Pushing typed arrays**: The second test case creates a typed array `Float32Array` and then pushes new instances of `Float32Array` into it using the `push()` method. This approach also creates a new array object on each push operation, but with a specific type (float32). 3. **Creating typed arrays in typed array**: The third test case creates a typed array `Float32Array` and then pushes new instances of `Float32Array` into it using the assignment operator (`a[i] = new Float32Array();`). This approach creates a new instance of `Float32Array` on each push operation, but within the context of an existing typed array. **Pros and Cons:** * **Pushing untyped arrays**: Pros - simple to implement, no additional overhead. Cons - can lead to performance issues due to the creation of multiple objects on each push operation. * **Pushing typed arrays**: Pros - creates a specific type of array, which can be beneficial in certain scenarios. Cons - may incur additional overhead due to the creation of new array objects, and the specific type of array may not always be necessary. * **Creating typed arrays in typed array**: Pros - reduces overhead compared to pushing typed arrays, as it avoids creating multiple array objects. Cons - requires more complex implementation, as each push operation must create a new instance within an existing context. **Library usage:** There is no explicit library usage mentioned in the benchmark definitions or test cases. **Special JS feature or syntax:** None of the provided test cases use any special JavaScript features or syntax. **Other considerations:** * The benchmark only compares the performance of these three approaches, so other factors like memory allocation, garbage collection, and concurrency may not be considered. * The benchmark assumes that the browser is running in a desktop environment (Windows) with a specific version of Firefox (128.0). **Alternatives:** If you wanted to create an alternative benchmark, you could consider adding more test cases to cover different scenarios, such as: * Creating arrays and typed arrays using `Array.from()` or `TypedArray.from()` * Using other methods for array creation (e.g., `Array.prototype.slice()` vs. `Array.prototype.push()`) * Comparing performance of different JavaScript engines or browsers * Adding more complex scenarios to simulate real-world usage patterns
Related benchmarks:
Push to array, vs ES6 Spread.
Spread vs Push when copying array
Array .push() vs .unshift() vs spread
Pushing items via Array.push vs. Spread Operator
Spread vs Push when adding into array
Comments
Confirm delete:
Do you really want to delete benchmark?