Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
test array and set 2
(version: 0)
Comparing performance of:
empty array vs array 10000 vs Int8Array vs Set
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
empty array
const a = new Array(1e4).fill(0) const d = new Int8Array(1e4) const c = [] const e = new Set() let b for (let i = 0; i < 1e4; i++) c[i] = i for (let i = 0; i < 1e4; i++) b = c[i]
array 10000
const a = new Array(1e4).fill(0) const d = new Int8Array(1e4) const c = [] const e = new Set() let b for (let i = 0; i < 1e4; i++) a[i] = i for (let i = 0; i < 1e4; i++) b = a[i]
Int8Array
const a = new Array(1e4).fill(0) const d = new Int8Array(1e4) const c = [] const e = new Set() let b for (let i = 0; i < 1e4; i++) d[i] = i for (let i = 0; i < 1e4; i++) b = d[i]
Set
const a = new Array(1e4).fill(0) const d = new Int8Array(1e4) const c = [] const e = new Set() let b for (let i = 0; i < 1e4; i++) e.add(i) for (let i = 0; i < 1e4; i++) b = e.has(i)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
empty array
array 10000
Int8Array
Set
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
empty array
26347.8 Ops/sec
array 10000
50701.7 Ops/sec
Int8Array
47329.4 Ops/sec
Set
3422.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Measuring JavaScript performance is crucial for optimizing applications and ensuring a seamless user experience. **Overview** The provided JSON represents a benchmark suite with four test cases, each testing different approaches to array creation and iteration in JavaScript. The tests aim to compare the performance of various data structures: arrays (empty, filled with zeros), `Int8Array`, and sets. **Test Cases** 1. **Empty Array**: This test creates an empty array using `const c = []` and then iterates over it using a `for` loop. 2. **Filled Array (10000 elements)**: Similar to the previous test, but this time creates an array filled with zeros using `new Array(1e4).fill(0)` and then iterates over it. 3. **Int8Array**: Creates an `Int8Array` instance with 10000 elements using `new Int8Array(1e4)`, populates it with values, and then iterates over it using a `for` loop. 4. **Set**: Creates a set using `const e = new Set()` and adds 10000 elements to it. Then, iterates over the set using the `has()` method. **Options Compared** The tests compare the following options: * Empty array vs filled array (empty) * Array creation using `new Array()`.fill(0)` vs creating an `Int8Array` instance * Set iteration using `has()` vs other approaches **Pros and Cons of Each Approach** 1. **Empty Array**: Pros: lightweight, easy to create; Cons: slower than other approaches due to the need for iteration. 2. **Filled Array (10000 elements)**: Pros: faster than empty array iterations; Cons: requires creating a large array. 3. **Int8Array**: Pros: uses a specialized buffer for efficient storage and iteration; Cons: may have performance overhead due to the use of an external buffer. 4. **Set**: Pros: provides fast lookup and iteration using `has()`; Cons: may incur additional memory allocation and iteration overhead. **Library and Purpose** The tests utilize the following libraries: * None (native JavaScript features) **Special JS Features or Syntax** None mentioned in the provided benchmark definition, but it's worth noting that other test cases might use more advanced features like async iterators or Web Workers for parallelization. **Other Alternatives** For measuring JavaScript performance, consider exploring the following alternatives: * V8 Benchmark Suite ( native JavaScript, Node.js) * jsperf (native JavaScript, browser-based) * Benchmark.js (Native and Browser-based) Note that these alternatives might have different features, focus areas, or usage models compared to MeasureThat.net. I hope this explanation helps you understand the provided benchmark definition and test cases!
Related benchmarks:
array assignment vs array fill
recreate array vs set 2
Create Set vs loop
Array push or set
set vs array find if exists v2
Comments
Confirm delete:
Do you really want to delete benchmark?