Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Immer vs Shallow copy vs Immutable Perf Test 3 (update library version)
(version: 0)
Comparing performance of:
immer vs shallow copy vs Immutable
Created:
5 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://unpkg.com/immer/dist/immer.umd.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.2/immutable.min.js"></script>
Script Preparation code:
//const { fromJS } = require('immutable'); var data = { items: {}, count: 0, keys: [] } for (let index = 0; index < 100; index++) { data[index] = { id: index, name: `ITEM-${index}`, value: Math.random() } data.count++ data.keys.push(index) } var NEW_ITEM_ID = data.count +1 var produce = immer.default var im = Immutable.fromJS(data);
Tests:
immer
data = produce(data, draft => { draft.items[NEW_ITEM_ID] = { id: NEW_ITEM_ID, name: 'ITEM-NEW', value: 0 } draft.counter++ draft.keys.push(NEW_ITEM_ID) })
shallow copy
data = { ...data, items: { ...data.items, [NEW_ITEM_ID]: { id: NEW_ITEM_ID, name: 'ITEM-NEW', value: 0 } }, count: data.count +1, keys: [ ...data.keys, NEW_ITEM_ID] }
Immutable
var um = im.set('items', im.get('items').set(NEW_ITEM_ID, { id: NEW_ITEM_ID, name: 'ITEM-NEW', value: 0 })); um = um.set('count', um.count +1); um = um.set('keys', um.get('keys').push(NEW_ITEM_ID));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
immer
shallow copy
Immutable
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!
Related benchmarks:
Immer vs Shallow copy vs Immutable Perf Test
Immer vs Shallow copy vs Immutable Perf Test 3
Immerjs vs Shallow copy vs Immutable Perf Test
Immer vs Shallow copy vs Immutable Perf Test updated
Comments
Confirm delete:
Do you really want to delete benchmark?