Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array vs int32Array
(version: 0)
Comparing performance of:
array reverse vs typedArray reverse vs array i/o vs typedArray i/o
Created:
6 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 Int32Array(10000)).map(_ => Math.random(1000000));
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:
14 days ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Browser/OS:
Chrome 147 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array reverse
157849.0 Ops/sec
typedArray reverse
458020.5 Ops/sec
array i/o
64218.1 Ops/sec
typedArray i/o
59784.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**What is being tested?** On MeasureThat.net, the provided JSON represents a JavaScript microbenchmarking test case. The benchmark tests two approaches to handling arrays and typed arrays: 1. **Arrays**: A standard JavaScript array (`a`) with 10,000 elements is created using `Array(10000)`. This array undergoes various operations: * Reversal: `a.reverse()` * Input/Output (I/O): Each element is incremented by 1 (`a[i] = a[i] + 1`) 2. **Typed Arrays**: An `Int32Array` (`ta`) with 10,000 elements is created using `new Int32Array(10000)`. This typed array also undergoes the same operations as the standard array. **Options compared** The benchmark compares two options: 1. **Standard JavaScript Array (a)**: Uses the built-in JavaScript array data structure. 2. **Typed Array (`ta`)**: Uses a specialized data structure optimized for numerical computations, `Int32Array`. **Pros and Cons of each approach** 1. **Standard JavaScript Array (a)**: * Pros: + Wide browser support + Easy to implement and use * Cons: + Performance may suffer compared to typed arrays for numerical computations 2. **Typed Array (`ta`)**: * Pros: + Optimized performance for numerical computations + May be faster than standard JavaScript arrays for these operations * Cons: + Less browser support compared to standard JavaScript arrays + May require more code to set up and use **Library and purpose** The `Int32Array` is a typed array data structure provided by the ECMAScript standard. It is designed to store 32-bit integers in an efficient manner, which makes it suitable for numerical computations. **Special JS feature or syntax** None mentioned in this specific benchmark case. **Other alternatives** If you need to handle large arrays or perform complex numerical computations, other options might include: 1. **WebAssembly**: A binary format that allows running languages like C or Rust on web browsers. 2. **Native ArrayBuffers**: Used in some libraries like Three.js for handling large amounts of 3D data. However, these alternatives are typically more complex to set up and use compared to standard JavaScript arrays and typed arrays.
Related benchmarks:
array vs int32array with conversion
array vs int32array without conversion
array vs float64 for io and slice
array vs float64 for io and slice (fixed)
array vs float32array max
Comments
Confirm delete:
Do you really want to delete benchmark?