Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
change Float64Array vs array.push (change)
(version: 0)
Comparing performance of:
typed array vs not typed array
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var size = 1024; var initialArray = []; for(let i = 0; i < size; i++) { initialArray.push(Math.random()); }
Tests:
typed array
const arr = new Float64Array(size); for(let i = 0; i < size; i++) { arr[i] = initialArray[i]/2; }
not typed array
const arr = []; for(let i = 0; i < size; i++) { arr.push(initialArray[i]/2); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
typed array
not typed array
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser/OS:
Firefox 145 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
typed array
644971.9 Ops/sec
not typed array
298478.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what is being tested. **Benchmark Purpose:** The goal of this benchmark is to compare the performance of two approaches when modifying an array in JavaScript: 1. Using a `Float64Array` (a typed array) instead of a regular `array`. 2. Modifying a regular `array` using the `push()` method. **Options Compared:** * **Typed Array (`Float64Array`)**: This option uses the `Float64Array` constructor to create an array with a specific data type (64-bit floating-point numbers). This can provide better performance and more precise calculations compared to using a regular `array`. * **Regular `array` with `push()` method**: This option uses the `push()` method to add elements to a regular `array`. While this is a common way to append elements, it may be slower than using a typed array or other optimized data structures. **Pros and Cons:** * **Typed Array (`Float64Array`)**: + Pros: - Can provide better performance due to more efficient memory management. - May offer more precise calculations for numerical computations. + Cons: - Limited support on older browsers or environments that don't understand typed arrays. - Requires additional setup and initialization before use. * **Regular `array` with `push()` method**: + Pros: - Wide compatibility across modern browsers and environments. - Easy to implement and set up. + Cons: - May be slower due to the overhead of the `push()` method. - Can lead to less precise calculations for numerical computations. **Library Used:** None, as this benchmark only uses built-in JavaScript features and data structures (arrays). **Special JS Feature/Syntax:** The benchmark does not utilize any special JavaScript features or syntax beyond what is commonly used in modern web development. No ES6+ features, no WebAssembly, etc. **Other Alternatives:** * Using other typed arrays like `Int32Array`, `Uint8Array`, or `BigInt64Array` might also be compared to see if they offer better performance. * Implementing a custom data structure or algorithm could be used as an alternative approach, but this would likely require significant changes to the benchmark. The current benchmark focuses on comparing the performance of using a typed array (`Float64Array`) versus a regular `array` with the `push()` method. If you'd like to explore other approaches or optimizations, feel free to modify the benchmark script and see how it affects the results!
Related benchmarks:
array vs float32array without conversion
Item getting in typed array vs simple array
array vs float64 for io and slice
array vs float64 for io and slice (fixed)
Comments
Confirm delete:
Do you really want to delete benchmark?