Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
object spread vs immutable-js set (4.0.0-rc.12) vs native Map
(version: 0)
Comparing performance of:
object spread vs immutable-js vs native Map
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/4.0.0-rc.12/immutable.js" integrity="sha512-LYupkoA9jinLFKys5IYhXa5kJgKNHBQ2G1KGrf+39Vm0zxuUCWoHJ0c3FHqacUhuTUbWFU9FWFTppIqKXs9UvQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Tests:
object spread
let obj = {}; for(i=0;i<100;i++){ const key = 'key'+i const value = 'value'+i obj = {...obj, [key]: {key, value}} }
immutable-js
let obj = Immutable.Map(); for(i=0;i<100;i++){ const key = 'key'+i const value = 'value'+i obj = obj.set(key, {key, value}) }
native Map
let obj = new Map(); for(i=0;i<100;i++){ const key = 'key'+i const value = 'value'+i obj.set(key, {key, value}) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
object spread
immutable-js
native Map
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark test and explain what's being tested. **Benchmark Overview** The benchmark compares the performance of three data structures for inserting key-value pairs into them: 1. **Immutable.js Set**: An immutable set implementation, which ensures that once an element is added to it, it cannot be modified. 2. **Native Map (JavaScript's built-in `Map`)**: A native JavaScript map implementation, which allows modifications through its methods like `set()`, `delete()` etc. 3. **Object Spread**: Using the spread operator (`...`) to merge objects, creating a new object with key-value pairs. **Options Compared** The options being compared are: 1. Immutable.js Set 2. Native Map (JavaScript's built-in `Map`) 3. Object Spread Each option has its pros and cons: * **Immutable.js Set**: + Pros: Ensures data consistency, immutability guarantees thread safety. + Cons: Insertion operations can be slower due to the need for creating a new set instance and adding elements to it. * **Native Map (JavaScript's built-in `Map`)**: + Pros: Fast insertion operations, flexible data structure with methods like `set()`, `delete()` etc. + Cons: May compromise immutability if modifications are made through these methods. * **Object Spread**: + Pros: Simple and concise syntax for creating new objects with merged key-value pairs. + Cons: Not optimized for insertion performance, may lead to slower execution times. **Library/Features Used** The test uses the following libraries/features: * Immutable.js (for its Set implementation) * JavaScript's built-in `Map` (native implementation) No special JavaScript features or syntax are used in this benchmark. It focuses on comparing the performance of different data structures for insertion operations. **Other Alternatives** For comparison, other alternatives could be considered, such as: 1. **Array**: Using arrays to store key-value pairs and inserting elements into them using methods like `push()`, `unshift()` etc. 2. **JSON Object**: Using JSON objects with the `Object.assign()` method or spread operator (`...`) for insertion operations. 3. **WeakMap**: JavaScript's built-in WeakMap implementation, which is a specialized map data structure that only stores references to keys and allows for efficient lookups. However, these alternatives are not included in the benchmark test provided.
Related benchmarks:
immutable vs lodash vs ... 4
Spread operator vs Immutable.js performance for common use cases
object spread vs immutable-js set vs native Map copy
object spread vs immutable-js set vs native Map vs object
Comments
Confirm delete:
Do you really want to delete benchmark?