Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array vs float64 for io and slice
(version: 0)
Comparing performance of:
array slice vs typedArray slice vs array i/o vs typedArray i/o
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } var a = [...Array(10000)].map(_ => Math.random(1000000)); var ta = (new Float64Array(10000)).map(_ => Math.random(1000000));
Tests:
array slice
a.slice(0);
typedArray slice
ta.slice(0);
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; } let tb = Array.from(ta);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
array slice
typedArray slice
array i/o
typedArray i/o
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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array slice
271419.8 Ops/sec
typedArray slice
24905.9 Ops/sec
array i/o
30760.6 Ops/sec
typedArray i/o
3398.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'd be happy to explain the benchmark being tested on MeasureThat.net. **Benchmark Definition** The benchmark is designed to compare the performance of JavaScript arrays and TypedArrays (Float64Arrays) in various operations, specifically slicing and modifying elements. **Test Cases** There are four test cases: 1. `array slice`: Measures the time it takes to execute the `a.slice(0)` operation. 2. `typedArray slice`: Measures the time it takes to execute the `ta.slice(0)` operation. 3. `array i/o`: Measures the time it takes to modify elements in an array using a loop (`for (let i = 0; i < 10000; ++i) { a[i] = a[i] + 1; }`). 4. `typedArray i/o`: Measures the time it takes to convert a Float64Array to an Array and then modify elements in the resulting array (`for (let i = 0; i < 10000; ++i) { ta[i] = ta[i] + 1; } let tb = Array.from(ta);`). **Comparison of Options** In each test case, two options are compared: * **Array**: The built-in JavaScript array type. * **TypedArray (Float64Array)**: A typed array that represents a sequence of 64-bit floating-point numbers. **Pros and Cons** Here's a brief summary of the pros and cons of each option: 1. `array slice`: * Pros: Fast, widely supported, easy to use. * Cons: May have performance issues for very large datasets or complex operations. 2. `typedArray slice`: * Pros: Can provide better performance for certain types of data (e.g., floating-point numbers) and may be more memory-efficient. * Cons: Less common usage, may require additional setup and configuration. 3. `array i/o`: * Pros: Fast, widely supported, easy to use. * Cons: May have performance issues for very large datasets or complex operations. 4. `typedArray i/o`: * Pros: Can provide better performance for certain types of data (e.g., floating-point numbers) and may be more memory-efficient. * Cons: Requires additional setup (converting to an Array), and the conversion process can introduce overhead. **Other Considerations** When choosing between arrays and TypedArrays, consider the following factors: * **Data type**: If you're working with floating-point numbers or other specialized data types, a TypedArray may be more suitable. * **Performance**: If you need optimized performance for large datasets or complex operations, consider using a TypedArray. * **Memory efficiency**: If memory is a concern, a TypedArray may be more efficient due to its ability to represent specific data types. **Library and Special JS Features** In the benchmark code, the following libraries are used: * `Float64Array`: A typed array that represents a sequence of 64-bit floating-point numbers. This library is built-in to JavaScript. * `Array.from()`: A method that converts an iterable object into an Array. This method is part of the modern JavaScript API. No special JS features or syntax are used in this benchmark. **Alternatives** If you're looking for alternatives to MeasureThat.net, consider the following options: * **Benchmarking libraries**: Libraries like Benchmark.js, Fast.js, or Microbenchmark allow you to write custom benchmarks and run them on different platforms. * **WebAssembly**: WebAssembly provides a platform-agnostic way to execute optimized code in the browser, which can be useful for benchmarking performance-critical code. Keep in mind that these alternatives may require more setup and configuration than MeasureThat.net.
Related benchmarks:
array vs float32array without conversion
array vs float32array without conversion 2
array vs float32array without conversion 3
array vs float64 for io and slice (fixed)
Comments
Confirm delete:
Do you really want to delete benchmark?