<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.2/immutable.min.js"></script>
var max = 10000000;
var array = [];
for (var i = 0; i < max; i++) {
array.push({
id: i
});
}
var result = Immutable.Map().asMutable();
for (var i = 0; i < array.lengh; i++) {
result.set(array[i].id, array[i])
}
return result.asImmutable();
var result = Immutable.OrderedMap().asMutable();
for (var i = 0; i < array.lengh; i++) {
result.set(array[i].id, array[i])
}
return result.asImmutable();
var result = Immutable.List().asMutable();
for (var i = 0; i < array.lengh; i++) {
result.push(array[i])
}
return result.asImmutable();
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Map | |
OrderedMap | |
List |
Test name | Executions per second |
---|---|
Map | 4420915.5 Ops/sec |
OrderedMap | 3515042.0 Ops/sec |
List | 3759088.2 Ops/sec |
Benchmark Overview
The provided JSON represents a JavaScript benchmarking test created using MeasureThat.net. The test compares the performance of three data structures: Immutable Map, Ordered Map, and List.
Options Compared
The benchmark tests the execution speed of each data structure when:
Pros and Cons of Each Approach
Libraries and Their Purpose
In the benchmark preparation code, two libraries are imported:
Special JS Features or Syntax
There is no special JavaScript feature or syntax mentioned in the provided benchmark code. The focus is on testing the performance of three data structures without using any advanced features like async/await, Promises, or Closures.
Other Alternatives
If you're interested in exploring alternative data structures for this use case, consider the following options:
Keep in mind that the choice of data structure depends on the specific requirements and constraints of your application. Always consider factors like thread-safety, predictability, and performance characteristics when selecting a data structure.