Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array vs Float64Array sort
(version: 0)
Comparing performance of:
array sort vs typedArray sort
Created:
4 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 sort
a.sort();
typedArray sort
ta.sort();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array sort
typedArray sort
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Browser/OS:
Chrome 141 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array sort
1818.5 Ops/sec
typedArray sort
40637.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview of the Benchmark** The provided benchmark tests the performance difference between sorting an untyped JavaScript array (`a`) and a typed array (`Float64Array`, `ta`). A typed array is a binary data type that provides more efficient memory management and improved performance compared to an untyped array. **Comparison Options** Two options are being compared: 1. **Untyped Array (a) Sort**: The first option compares the performance of sorting an untyped JavaScript array (`a`). 2. **TypedArray Sort (ta)**: The second option compares the performance of sorting a typed array (`Float64Array`, `ta`). **Pros and Cons of Each Approach** * **Untyped Array (a) Sort**: + Pros: Easy to create and manipulate, no special setup required. + Cons: Less efficient than typed arrays due to dynamic memory allocation and type checking. * **TypedArray Sort (ta)**: + Pros: More efficient due to better memory management, improved performance, and reduced type checking overhead. + Cons: Requires creating a typed array instance before sorting. **Library Used** The `Float64Array` is a JavaScript built-in class that represents an array of 64-bit floating-point numbers. Its purpose is to provide more efficient storage and manipulation of large numerical arrays compared to untyped arrays. **Special JS Feature/Syntax** There are no special JavaScript features or syntax being used in this benchmark beyond the use of typed arrays. **Other Alternatives** Alternative approaches to sorting an array could include: * Using a library like Lodash or Array.prototype.sort() with options (e.g., `sort()` with `{ unstable: true }` for stability). * Using a parallel processing framework like Web Workers to sort multiple arrays concurrently. * Implementing a custom sorting algorithm, such as quicksort or mergesort. Keep in mind that these alternatives may not directly compare to the typed array approach being tested here.
Related benchmarks:
array vs float32array without conversion
array vs float32array withoutconversion
array vs float32array without conversion 2
array vs Float64Array (small) 2
Comments
Confirm delete:
Do you really want to delete benchmark?