Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array vs Float64Array
(version: 0)
Comparing performance of:
array reverse vs typedArray reverse vs array i/o vs typedArray i/o
Created:
7 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var a = [...Array(10000)].map(_ => Math.random()); var ta = (new Float64Array(10000)).map(_ => Math.random());
Tests:
array reverse
a.reverse();
typedArray reverse
ta.reverse();
array i/o
for (let i = 0; i < 10000; ++i) a[i] = a[i] + 1;
typedArray i/o
for (let i = 0; i < 10000; ++i) ta[i] = ta[i] + 1;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
array reverse
typedArray reverse
array i/o
typedArray i/o
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Browser/OS:
Chrome 144 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array reverse
59532.6 Ops/sec
typedArray reverse
191536.1 Ops/sec
array i/o
16307.2 Ops/sec
typedArray i/o
15105.3 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview of the Benchmark** MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The provided benchmark compares the performance of arrays (native JavaScript data structure) with Float64Array (a typed array for 64-bit floating-point numbers). The test cases focus on common operations like reversing an array, assigning values to elements in an array, and accessing elements in a typed array. **Options Compared** The benchmark compares two approaches: 1. **Native Array**: Using native JavaScript arrays for all operations. 2. **TypedArray**: Using Float64Array (a typed array) instead of native arrays for some operations. **Pros and Cons** **Native Array:** Pros: * No additional setup required * Native support, so no need to include libraries or polyfills Cons: * Performance might be slower due to overhead of JavaScript interpretation * Can lead to slower execution times compared to typed arrays **TypedArray (Float64Array):** Pros: * Can provide faster execution times for certain operations * Typed arrays are optimized for performance and memory usage Cons: * Requires additional setup with the `Float64Array` constructor * Might require including libraries or polyfills if not supported natively **Library Used:** In this benchmark, no specific library is mentioned. However, Float64Array is a native JavaScript data structure that does not require any external libraries. **Special JS Feature or Syntax:** There are no special JavaScript features or syntaxes used in this benchmark. The tests only involve basic arithmetic operations and array manipulations. **Other Alternatives:** To improve performance, alternative approaches can be explored: * Using WebAssembly (WASM) for execution * Compiling the script to native machine code using tools like V8 or SpiderMonkey * Optimizing JavaScript code with techniques like memoization or caching Keep in mind that these alternatives may require additional setup and expertise. **Benchmark Preparation Code Explanation** The preparation code is used to create an array of 10,000 random numbers and another typed array (Float64Array) for the same purpose: ```javascript var a = [...Array(10000)].map(_ => Math.random()); // native array var ta = (new Float64Array(10000)).map(_ => Math.random()); // typed array ``` This code uses the spread operator (`...`) to create an array from an array expression, which is then used in a `map` function to generate random numbers. For the typed array, it creates a new Float64Array instance and maps over its elements using the same random number generator. **Individual Test Cases:** Each test case measures the performance of a specific operation: * `array reverse`: Reverses the native array * `typedArray reverse`: Reverses the typed array (Float64Array) * `array i/o` : Assigns values to elements in the native array, then accesses those values. * `typedArray i/o`: Assigns values to elements in the typed array (Float64Array), then accesses those values. These tests are designed to identify any potential performance differences between using native arrays and typed arrays for specific operations.
Related benchmarks:
array vs Float64Array vs Float32Array
array vs Float64Array (small) 2
array vs Float64Array sort
array vs Float64Array vs mixed array
new Array() vs Array.from() with random data
Comments
Confirm delete:
Do you really want to delete benchmark?