Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
TESTSort2
(version: 0)
Comparing performance of:
JS vs Typed
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var nums = Array.from({length: 1000}, () => Math.random() * 100 |0) var unums = new Uint16Array(nums);
Tests:
JS
nums.sort((x,y) => x-y)
Typed
unums.sort((x,y) => x-y)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
JS
Typed
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:126.0) Gecko/20100101 Firefox/126.0
Browser/OS:
Firefox 126 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
JS
84241.0 Ops/sec
Typed
25057.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** The provided JSON represents a JavaScript microbenchmark, specifically designed to measure the performance difference between two approaches: JavaScript and typed arrays. **Script Preparation Code** The script preparation code creates an array of 1000 random numbers using `Array.from()` and converts it to a Uint16Array (`unums`) for comparison. This setup allows for direct comparisons between the JavaScript array implementation and the optimized typed array implementation. **Html Preparation Code** There is no html preparation code provided, which means that the benchmark does not take into account any HTML-specific optimizations or features. **Test Cases** The benchmark consists of two test cases: 1. **JS**: This test case uses the standard JavaScript array implementation, where an array (`nums`) is created and sorted using the `sort()` method with a custom comparison function. 2. **Typed**: This test case uses the typed array implementation, where the same array data is converted to a Uint16Array (`unums`) and sorted using the same comparison function. **Comparison of Options** The two approaches differ in how they store and manipulate the data: * **JavaScript Array (JS)**: + Pros: Easy to implement, no additional dependencies required. + Cons: May incur overhead due to JavaScript's dynamic nature and slower performance compared to typed arrays. * **Typed Array (Typed)**: + Pros: Provides optimized storage and manipulation for numerical data, often leading to better performance. + Cons: Requires an additional library or syntax change. **Library Used** The `Uint16Array` is a part of the JavaScript standard library, which provides a typed array implementation for 16-bit integers. Its purpose is to offer more efficient memory usage and operations compared to regular arrays. **Special JS Feature/Syntax** There are no special JavaScript features or syntax used in this benchmark. However, it's worth noting that some newer JavaScript versions (e.g., ECMAScript 2022) may introduce new features or improvements that could impact performance, but those are not applicable to this specific benchmark. **Alternative Approaches** Other alternatives for similar benchmarks might include: * **NativeArray**: A native array implementation for numerical data, which is often optimized for performance. * **WebAssembly**: A binary format that can be used to compile languages like C++ or Rust into a web-friendly format, potentially offering better performance than JavaScript arrays or typed arrays. Keep in mind that the choice of approach depends on the specific requirements and constraints of the benchmark, such as ease of implementation, compatibility with different browsers or environments, and desired performance characteristics.
Related benchmarks:
array vs int32array with conversion
array vs int32array without conversion
Lodash 4.17.21 sort vs array.prototype.sort
sort variants test
Sorting test U
Comments
Confirm delete:
Do you really want to delete benchmark?