Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash merge vs custom merge js
(version: 0)
Comparing performance of:
lodash merge vs custom merge
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
function customMerge(target, source) { // Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties for (const key of Object.keys(source)) { if (source[key] instanceof Object) Object.assign(source[key], customMerge(target[key], source[key])) } // Join `target` and modified `source` Object.assign(target || {}, source) return target }
Tests:
lodash merge
var a = { "_id": "66fbb8cedd880f8726d3430d", "index": 0, "guid": "0a9b7fd8-2e1c-423e-9129-a4b34edd6ea0", "isActive": false, "balance": "$3,498.70", "picture": "http://placehold.it/32x32", "age": 31, "eyeColor": "blue", "name": "Estrada Mcfarland", "gender": "male", "company": "BULLZONE", "email": "estradamcfarland@bullzone.com", "phone": "+1 (875) 565-3286", "address": "344 Oakland Place, Caledonia, Ohio, 8843", "about": "Cupidatat velit minim Lorem quis non. Ullamco magna qui commodo aliquip cillum anim ea aliqua. Tempor ullamco nulla cillum mollit veniam tempor ipsum ipsum culpa ipsum. Quis sit velit minim ad eiusmod veniam aliquip non anim veniam anim enim est cupidatat. Pariatur ipsum ipsum commodo irure laborum qui velit do est ullamco. Tempor velit ullamco Lorem non laboris culpa ullamco excepteur aliquip laboris cillum occaecat adipisicing anim.\r\n", "registered": "2014-01-31T12:10:19 -07:00", "latitude": 37.048423, "longitude": 131.714333, "tags": [ "reprehenderit", "ea", "esse", "ipsum", "Lorem", "dolor", "non" ], "friends": [ { "id": 0, "name": "Bender Battle" }, { "id": 1, "name": "Flowers Huff" }, { "id": 2, "name": "Amanda Armstrong" }]}; var b = { "_id": "66fbb8fb871c6f25070b297b", "index": 0, "guid": "65f9bf15-96b5-4e1c-8d17-a7b9f9f52cf3", "isActive": false, "balance": "$2,098.99", "picture": "http://placehold.it/32x32", "age": 39, "eyeColor": "blue", "name": "Cherry Hendrix", "gender": "female", "company": "MAGNINA", "email": "cherryhendrix@magnina.com", "phone": "+1 (842) 469-3783", "address": "645 Myrtle Avenue, Sharon, Nevada, 4405", "about": "Consequat Lorem Lorem quis ea mollit Lorem deserunt eiusmod elit. Eu est duis in incididunt exercitation consequat duis sint quis adipisicing nisi. Quis sunt excepteur laborum cillum cillum ea ullamco tempor duis esse eiusmod laboris. Velit aliquip consequat ullamco laboris laboris sit cillum commodo fugiat labore sint cillum consequat.\r\n", "registered": "2023-06-02T08:28:00 -07:00", "latitude": -67.322848, "longitude": 19.323204, "tags": [ "amet", "laboris", "cillum", "irure", "velit", "officia", "in" ], "friends": [ { "id": 0, "name": "Shanna Shelton" }, { "id": 1, "name": "Lucile Kelley" }, { "id": 2, "name": "Walker Hall" } ], "greeting": "Hello, Cherry Hendrix! You have 3 unread messages.", "favoriteFruit": "apple" }; var c = _.merge(a, b);
custom merge
var a = { "_id": "66fbb8cedd880f8726d3430d", "index": 0, "guid": "0a9b7fd8-2e1c-423e-9129-a4b34edd6ea0", "isActive": false, "balance": "$3,498.70", "picture": "http://placehold.it/32x32", "age": 31, "eyeColor": "blue", "name": "Estrada Mcfarland", "gender": "male", "company": "BULLZONE", "email": "estradamcfarland@bullzone.com", "phone": "+1 (875) 565-3286", "address": "344 Oakland Place, Caledonia, Ohio, 8843", "about": "Cupidatat velit minim Lorem quis non. Ullamco magna qui commodo aliquip cillum anim ea aliqua. Tempor ullamco nulla cillum mollit veniam tempor ipsum ipsum culpa ipsum. Quis sit velit minim ad eiusmod veniam aliquip non anim veniam anim enim est cupidatat. Pariatur ipsum ipsum commodo irure laborum qui velit do est ullamco. Tempor velit ullamco Lorem non laboris culpa ullamco excepteur aliquip laboris cillum occaecat adipisicing anim.\r\n", "registered": "2014-01-31T12:10:19 -07:00", "latitude": 37.048423, "longitude": 131.714333, "tags": [ "reprehenderit", "ea", "esse", "ipsum", "Lorem", "dolor", "non" ], "friends": [ { "id": 0, "name": "Bender Battle" }, { "id": 1, "name": "Flowers Huff" }, { "id": 2, "name": "Amanda Armstrong" }]}; var b = { "_id": "66fbb8fb871c6f25070b297b", "index": 0, "guid": "65f9bf15-96b5-4e1c-8d17-a7b9f9f52cf3", "isActive": false, "balance": "$2,098.99", "picture": "http://placehold.it/32x32", "age": 39, "eyeColor": "blue", "name": "Cherry Hendrix", "gender": "female", "company": "MAGNINA", "email": "cherryhendrix@magnina.com", "phone": "+1 (842) 469-3783", "address": "645 Myrtle Avenue, Sharon, Nevada, 4405", "about": "Consequat Lorem Lorem quis ea mollit Lorem deserunt eiusmod elit. Eu est duis in incididunt exercitation consequat duis sint quis adipisicing nisi. Quis sunt excepteur laborum cillum cillum ea ullamco tempor duis esse eiusmod laboris. Velit aliquip consequat ullamco laboris laboris sit cillum commodo fugiat labore sint cillum consequat.\r\n", "registered": "2023-06-02T08:28:00 -07:00", "latitude": -67.322848, "longitude": 19.323204, "tags": [ "amet", "laboris", "cillum", "irure", "velit", "officia", "in" ], "friends": [ { "id": 0, "name": "Shanna Shelton" }, { "id": 1, "name": "Lucile Kelley" }, { "id": 2, "name": "Walker Hall" } ], "greeting": "Hello, Cherry Hendrix! You have 3 unread messages.", "favoriteFruit": "apple" }; var c = customMerge(a,b);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash merge
custom merge
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser/OS:
Chrome 128 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash merge
308380.8 Ops/sec
custom merge
133812.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll provide an answer. It appears that you are experiencing issues with your code and need help debugging or troubleshooting it. However, I don't see any specific code snippet in your message that would allow me to identify the issue. If you could provide more context or details about what's not working as expected, such as error messages, code snippets, or the exact problem you're facing, I'd be happy to try and assist you further.
Related benchmarks:
lodash merge vs object.assign vs spread overwriting one property
Array Properties Merge: Lodash merge vs Object.assign
lodash merge vs object.assign vs spread (no intermediate vars)
lodash assign vs object.assign vs spread operator - variable and constant
Comments
Confirm delete:
Do you really want to delete benchmark?