Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Deep merge lodash vs ramda vs deepmerge vs es-toolkit vs deepMergeRightOnPlace
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0
Browser:
Firefox 144
Operating system:
Linux
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
Ramda.mergeDeepRight
1955727.6 Ops/sec
Lodash.merge
1200758.5 Ops/sec
deepmerge
88633.0 Ops/sec
es-toolkit merge
263401.3 Ops/sec
deepmergeRightOnPlace
3048754.2 Ops/sec
deepMergeRightOnPlace2
2282687.0 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/es-toolkit/dist/browser.global.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/lodash.merge/index.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/ramda/dist/ramda.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/deepmerge/dist/umd.min.js"></script>
Script Preparation code:
function isObject(x) { return Object.prototype.toString.call(x) === '[object Object]';} function deepMergeRightOnPlace(target, source) { for (const key in source) { if (source.hasOwnProperty(key)) { const sourceVal = source[key]; const targetVal = target[key]; if ( isObject(sourceVal) && isObject(targetVal) ) { // Рекурсивное объединение вложенных объектов deepMergeRightOnPlace(targetVal, sourceVal); } else { // Перезапись значения target[key] = sourceVal; } } } return target; } function deepMergeRightOnPlace2(ref, source) { const keys = Object.keys(source); for (let i = 0; i < keys.length; i += 1) { const key = keys[i]; if (source.hasOwnProperty(key)) { const sourceVal = source[key]; const targetVal = ref[key]; if (isObject(sourceVal) && isObject(targetVal)) { deepMergeRightOnPlace(targetVal, sourceVal); } else { ref[key] = sourceVal; } } } }; var obj1 = { "a": "0001", "b": "donut", "c": "Cake", "d": 0.55, "e": { "ea": [ { "id": "1001", "type": "Regular" }, { "id": "1002", "type": "Chocolate" }, { "id": "1003", "type": "Blueberry" }, { "id": "1004", "type": "Devil's Food" } ] }, "f": [ { "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" } ] }; var obj2 = { "a": "0003", "b": "Overwritten", "c": "Old Fashioned", "d": 0.55, "e": { "ea": [ { "id": "1001", "type": "Overwritten" }, { "id": "1002", "type": "Chocolate" } ] }, "f": [ { "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)
es-toolkit merge
_.merge(obj1, obj2)
deepmergeRightOnPlace
deepMergeRightOnPlace(obj1, obj2)
deepMergeRightOnPlace2
deepMergeRightOnPlace2(obj1, obj2)