Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Deep merge lodash vs ramda vs deepmerge vs json clone 3
(version: 0)
Comparing performance of:
Ramda.mergeDeepRight vs Lodash.merge vs deepmerge vs json clone vs Lodash.merge immutable vs StructuredClone
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="//cdn.jsdelivr.net/npm/ramda@latest/dist/ramda.min.js"></script> <script src="https://raw.githubusercontent.com/lodash/lodash/4.17.15-npm/lodash.js"></script> <script src="https://unpkg.com/deepmerge/dist/umd.js"></script>
Script Preparation code:
var obj1 = [ { "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Regular" }, { "id": "1002", "type": "Chocolate" }, { "id": "1003", "type": "Blueberry" }, { "id": "1004", "type": "Devil's Food" } ] }, "topping": [ { "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5005", "type": "Sugar" }, { "id": "5007", "type": "Powdered Sugar" }, { "id": "5006", "type": "Chocolate with Sprinkles" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] }, { "id": "0002", "type": "donut", "name": "Raised", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Regular" } ] }, "topping": [ { "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5005", "type": "Sugar" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] }, { "id": "0003", "type": "donut", "name": "Old Fashioned", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Regular" }, { "id": "1002", "type": "Chocolate" } ] }, "topping": [ { "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] } ] var obj2 = [ { "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Overwritten" }, { "id": "1002", "type": "Chocolate" }, { "id": "1003", "type": "Overwritten" }, { "id": "1004", "type": "Devil's Food" } ] }, "topping": [ { "id": "5001", "type": "Overwritten" }, { "id": "5002", "type": "Overwritten" }, { "id": "5005", "type": "Sugar" }, { "id": "5007", "type": "Powdered Sugar" }, { "id": "5006", "type": "Chocolate with Sprinkles" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Overwritten" } ] }, { "id": "0002", "type": "Overwritten", "name": "Raised", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Overwritten" } ] }, "topping": [ { "id": "5001", "type": "None" }, { "id": "5002", "type": "Overwritten" }, { "id": "5005", "type": "Sugar" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] }, { "id": "0003", "type": "Overwritten", "name": "Old Fashioned", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Overwritten" }, { "id": "1002", "type": "Chocolate" } ] }, "topping": [ { "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] } ]
Tests:
Ramda.mergeDeepRight
R.mergeDeepRight(obj1, obj2)
Lodash.merge
_.merge(obj1, obj2)
deepmerge
deepmerge(obj1, obj2)
json clone
JSON.parse(JSON.stringify(obj1))
Lodash.merge immutable
_.merge({}, obj1, obj2)
StructuredClone
structuredClone(obj1, obj2)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (6)
Previous results
Fork
Test case name
Result
Ramda.mergeDeepRight
Lodash.merge
deepmerge
json clone
Lodash.merge immutable
StructuredClone
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):
The benchmark results are as follows: 1. Ramda.mergeDeepRight: **250,241 executions per second** ( Firefox 111 on Mac OS X 10.15) 2. Lodash.merge: **169,163 executions per second** (Firefox 111 on Mac OS X 10.15) 3. deepmerge: **110,401 executions per second** (Firefox 111 on Mac OS X 10.15) 4. JSON.parse(JSON.stringify(obj1)): **62512 executions per second** (Firefox 111 on Mac OS X 10.15) 5. Lodash.merge immutable: **39471 executions per second** (Firefox 111 on Mac OS X 10.15) 6. StructuredClone: **32540 executions per second** (Firefox 111 on Mac OS X 10.15) Note that these results are for a specific browser and operating system, and may vary depending on other factors such as hardware and software configurations. It appears that: * Ramda.mergeDeepRight is the fastest, followed closely by deepmerge. * Lodash.merge is slower than the others. * JSON.parse(JSON.stringify(obj1)) is relatively slow compared to the other benchmarks. * Lodash.merge immutable is slower than its non-immutable counterpart. These results suggest that Ramda's mergeDeepRight function may be a good choice for merging complex objects, while deepmerge might be a better option for simple merges. However, it's essential to consider other factors such as performance and compatibility when selecting a library or implementation.
Related benchmarks:
RFDC clone vs Lodash clone vs JSON Clone
RFDC clone vs clone-deep clone vs Lodash cloneDeep vs JSON Clone
Deep merge lodash vs ramda vs deepmerge vs json clone
RFDC clone vs Lodash cloneDeep vs JSON Clone vs structured clone
Object Cloning Comparsion
Comments
Confirm delete:
Do you really want to delete benchmark?