Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Immer & Immutable benchmarks with inceremntal data
(version: 0)
Comparing performance of:
immer many shorts updates vs immer one big update vs immer balanced data change vs immutable vs immutable balanced data change
Created:
3 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/immer/9.0.17/immer.umd.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/4.2.2/immutable.min.js"></script>
Script Preparation code:
var INITIAL_DATA = { items: {}, count: 0, keys: [] } var produce = immer.default var iterationTop = 30; var iterationBottom = 70; var iterationFull = iterationTop * iterationBottom;
Tests:
immer many shorts updates
let data = INITIAL_DATA; for (i = 0; i < iterationFull; i++) { data = produce(data, draft => { draft.items[i] = { id: i, name: `NEW-ITEM${i}`, value: i } draft.counter++ draft.keys.push(`NEW-ITEM${i}`) }) }
immer one big update
let data = INITIAL_DATA; data = produce(data, draft => { for (i = 0; i < iterationFull; i++) { draft.items[i] = { id: i, name: `NEW-ITEM${i}`, value: i } draft.counter++ draft.keys.push(`NEW-ITEM${i}`) } })
immer balanced data change
let data = INITIAL_DATA; for (i = 0; i < iterationTop; i++) { data = produce(data, draft => { for (x = 0; x < iterationBottom; x++) { const id = `${i}-${x}` draft.items[id] = { id: id, name: `NEW-ITEM${id}`, value: id } draft.count++ draft.keys.push(`NEW-ITEM${id}`) } }) }
immutable
let immData = Immutable.Record({ items: Immutable.Map({}), count: 0, keys: Immutable.List([]) })(); for (i = 0; i < iterationFull; i++) { immData = immData.update("items", (items) => { return items.set( i, Immutable.Record({ id: i, name: `NEW-ITEM${i}`, value: i })() ); }); immData = immData.set("count", immData.get("count") + 1); immData = immData.update("keys", (keys) => keys.push(`NEW-ITEM${i}`)); }
immutable balanced data change
let immData = Immutable.Record({ items: Immutable.Map({}), count: 0, keys: Immutable.List([]) })(); for (i = 0; i < iterationTop; i++) { immData = immData.update("items", (items) => { let immItems = items; for (x = 0; x < iterationBottom; x++) { const id = `${i}-${x}`; immItems = immItems.set( id, Immutable.Record({ id: id, name: `NEW-ITEM${id}`, value: id })() ); return immItems; } }); } for (i = 0; i < iterationFull; i++) { immData = immData.set("count", immData.get("count") + 1); immData = immData.update("keys", (keys) => keys.push(`NEW-ITEM${i}`)); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
immer many shorts updates
immer one big update
immer balanced data change
immutable
immutable balanced data change
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.1:latest
, generated one year ago):
Let's dive into the provided JSON data and benchmark results. **What is being tested?** The benchmark is testing two popular JavaScript libraries for managing immutable data: Immer and Immutable.js. The tests are designed to measure the performance of these libraries when updating data in various scenarios. **Test cases:** 1. **Immer "many short updates"**: This test creates an initial data object, then repeatedly applies a small number of updates (30-70) to the object using Immer's `produce` function. 2. **Immer "one big update"**: Similar to the previous test, but instead of many short updates, this test applies a single large update to the object. 3. **Immer "balanced data change"**: This test creates an initial data object with a specific structure (top-level items and sub-items), then repeatedly updates the object by adding new top-level items with multiple sub-items. 4. **Immutable.js "immutable"**: This test creates an Immutable Map, List, and Record objects, then repeatedly updates the map by setting a single item at a time. 5. **Immutable.js "balanced data change"**: Similar to the Immer balanced data change test, but using Immutable.js's update functions. **What options are compared?** The tests compare the performance of Immer and Immutable.js in various scenarios: * Updating a large number of small items (Immer many short updates vs. Immutable one big update) * Updating a single large item with multiple sub-items (Immer balanced data change vs. Immutable balanced data change) **Performance results:** The latest benchmark result shows the Execution Per Second (EPS) values for each test: | Test Name | Executions Per Second | | --- | --- | | immutable balanced data change | 722.3770751953125 | | immer one big update | 256.2586364746094 | | immutable | 96.40592193603516 | | immer balanced data change | 26.842477798461914 | | immer many shorts updates | 1.1208966970443726 | **Interpretation:** The results show that Immutable.js performs significantly better than Immer in most scenarios, with execution speeds up to 650 times faster. However, the difference is most pronounced when updating a large number of small items (Immer many short updates vs. Immutable one big update). In contrast, Immer performs relatively well when updating a single large item with multiple sub-items (Immer balanced data change), but still lags behind Immutable.js. Keep in mind that these results are specific to the test environment and may not reflect real-world usage patterns. Nonetheless, they provide valuable insights into the performance characteristics of these two popular immutable data management libraries.
Related benchmarks:
Immerjs vs Immutable Perf Test
object spread vs immutable-js set vs simmer
object spread vs immutable-js set vs immer
object spread vs immutable-js set vs immer 2
Comments
Confirm delete:
Do you really want to delete benchmark?