Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash cloneDeep vs structuredClone (specific use case)
(version: 0)
https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
Comparing performance of:
Lodash cloneDeep vs Native structuredClone
Created:
3 years ago
by:
Registered User
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:
var MyObject = { "home": { "sasdfsdfsdfsdf": { "heading": "sdfsdfdsfdsfdsfd", "subheading": "Esdfdsxpedsfdsfdsfdia Tesdfdsfsdfy", "link": { "uiLink": { "text": "View profile", "__typename": "sdfdsfdsfsdfdStandardLink" }, "action": { "primary": { "resource": { "value": "dfsfsdfsdfsdfsfsdfsdfsdfdsfdfsdfdsfsdfsdfsadfasfsfsd/users/#profile", "__typename": "HttpURI" }, "analytics": { "referrerId": "Sasdfdsfdsfn.ViewProfile.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" }, "__typename": "HomeAction" }, "__typename": "HomeStandardLink" }, "__typename": "Hodsfsdfdssd" }, "sdfsdfdsComponent": null, "sdsfdsdsfdsfComponent": null, "sdsfsdfdsfdsComponent": { "draftsdsfdsdsfdsf": { "heading": "Draft trips", "carousel": { "items": [ { "__typename": "TripImageCard", "primaryText": "Rio de Janeiro", "secondaryText": "Mon, Sep 5 - Sat, Sep 10", "background": { "__typename": "Image", "url": "https://dfdfsdfsdfdsfsdfdfdf/mobile/placeholder-trip.jpg", "description": "" }, "action": { "__typename": "TripAction", "primary": { "resource": { "value": "dfsfsdfsdfsdfsfsdfsdfsdfdsfdfsdfdsfsdfsdfsadfasfsfsd/trip-webapp/0000-2966-444", "__typename": "HttpURI" }, "analytics": { "referrerId": "sdsfsdfdsfds.Trip1.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" } }, "primaryBadge": { "text": "Draft", "icon": null, "style": "VIP_ACCESS", "__typename": "Badge" }, "lobBadges": [ { "text": null, "icon": { "__typename": "Icon", "id": "lob_flights", "token": "icon__lob_flights" }, "style": "LOB", "__typename": "Badge" } ] }, { "__typename": "TripImageCard", "primaryText": "Stockholm", "secondaryText": "Wed, Sep 7 - Thu, Sep 8", "background": { "__typename": "Image", "url": "https://sdfasdfasdfasdfsdfsdfasdfsdafsdfsdfasdfadsfsd/destination/arn_640_324.jpg", "description": "" }, "action": { "__typename": "TripAction", "primary": { "resource": { "value": "dfsfsdfsdfsdfsfsdfsdfsdfdsfdfsdfdsfsdfsdfsadfasfsfsd/trip-webapp/0000-2990-302", "__typename": "HttpURI" }, "analytics": { "referrerId": "sdsfsdfdsfds.Trip2.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" } }, "primaryBadge": { "text": "Draft", "icon": null, "style": "VIP_ACCESS", "__typename": "Badge" }, "lobBadges": [ { "text": null, "icon": { "__typename": "Icon", "id": "lob_flights", "token": "icon__lob_flights" }, "style": "LOB", "__typename": "Badge" } ] }, { "__typename": "TripImageCard", "primaryText": "Delhi", "secondaryText": "Mon, Sep 19 - Mon, Sep 26", "background": { "__typename": "Image", "url": "https://sdfasdfasdfasdfsdfsdfasdfsdafsdfsdfasdfadsfsd/destination/del_640_324.jpg", "description": "" }, "action": { "__typename": "Tsdfsdfasdfd", "primary": { "resource": { "value": "dfsfsdfsdfsdfsfsdfsdfsdfdsfdfsdfdsfsdfsdfsadfasfsfsd/trip-webapp/0000-2971-820", "__typename": "HttpURI" }, "analytics": { "referrerId": "sdsfsdfdsfds.Trip3.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" } }, "primaryBadge": { "text": "Draft", "icon": null, "style": "VIP_ACCESS", "__typename": "Badge" }, "lobBadges": [ { "text": null, "icon": { "__typename": "Icon", "id": "lob_flights", "token": "icon__lob_flights" }, "style": "LOB", "__typename": "Badge" } ] }, { "__typename": "Trisdfsdfdsard", "primaryText": "Pittsburgh (Union Station), PA", "secondaryText": "Mon, Oct 10 - Thu, Oct 27", "background": { "__typename": "Image", "url": "https://isdfsdfdsdsd/mobiata/mobile/web/destination/txl_640_324.jpg", "description": "" }, "action": { "__typename": "Trsdfdsdstion", "primary": { "resource": { "value": "https://sdfsdfdsfsd/trsdfdp/0000-2970-427", "__typename": "HttpURI" }, "analytics": { "referrerId": "sdsfsdfdsfds.Trip4.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" } }, "primaryBadge": { "text": "Draft", "icon": null, "style": "VIP_ACCESS", "__typename": "Badge" }, "lobBadges": [ { "text": null, "icon": { "__typename": "Icon", "id": "lob_flights", "token": "icon__lob_flights" }, "style": "LOB", "__typename": "Badge" }, { "text": null, "icon": { "__typename": "Icon", "id": "train", "token": "icon__train" }, "style": "LOB", "__typename": "Badge" }, { "text": null, "icon": { "__typename": "Icon", "id": "lob_cars", "token": "icon__lob_cars" }, "style": "LOB", "__typename": "Badge" } ] }, { "__typename": "TripImageCard", "primaryText": "Rio de Janeiro", "secondaryText": "Wed, Nov 16 - Thu, Nov 24", "background": { "__typename": "Image", "url": "https://dfdsfdsfdsfdsfdfdf/mobiata/mobile/web/destination/gig_640_324.jpg", "description": "" }, "action": { "__typename": "TripAction", "primary": { "resource": { "value": "https://sdfdsdsfdsfddfsd/trip-webapp/0000-2970-509", "__typename": "HttpURI" }, "analytics": { "referrerId": "sdsfsdfdsfds.Trip5.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" } }, "primaryBadge": { "text": "Draft", "icon": null, "style": "VIP_ACCESS", "__typename": "Badge" }, "lobBadges": [ { "text": null, "icon": { "__typename": "Icon", "id": "lob_flights", "token": "icon__lob_flights" }, "style": "LOB", "__typename": "Badge" } ] } ], "__typename": "sdfdsfdsfsdfdStandardCarousel" }, "secondaryButton": { "__typename": "TripSecondaryButton", "button": { "primary": "See all trips", "__typename": "UISecondaryButton" }, "action": { "__typename": "TripAction", "primary": { "resource": { "value": "www.cnn.com", "__typename": "HttpURI" }, "analytics": { "referrerId": "sdsfsdfdsfds.SeeAll.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" } } }, "__typename": "sdsfdsdsfdsf" }, "emptyState": null, "__typename": "sdsfsdfdsfdsComponent" }, "sdfsdfdsfdsfdsComponent": { "sdfdsfdsfsdfdCard": { "cardBackground": "PRIMARY", "cardBorder": "DEFAULT", "cardPattern": { "mainContent": { "heading": "sdfsdfdsfds with confidence", "message": "See the latest sdfsdfdsfds advisories, restrictions and news updates.", "primaryLink": { "action": { "resource": { "value": "sdfsdfdsfsadfsfsdfds", "__typename": "HttpURI" }, "analytics": { "referrerId": "", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" }, "sdfdsfdsfsdfdElementId": null, "icon": null, "iconPosition": null, "size": "MEDIUM", "text": "sdfsdfsdfsdfdsfadsfadsfsdfdsfds", "__typename": "sdfdsfdsfsdfdStandardLink" }, "secondaryLink": null, "uiGraphic": { "__typename": "Icon", "id": "protect", "token": "icon__protect" }, "primaryAction": { "resource": { "type": "updateCount", "value": "dfsfsdfsdfsdfsfsdfsdfsdfdsfdfsdfdsfsdfsdfsadfasfsfsd/sdfsdfdsfds-advisor", "__typename": "dispatch" }, "analytics": { "referrerId": "sdfsdfdsfdsfds.sdfsdfasfsdfadsfasd", "__typename": "ClientSideAnalytics" }, "__typename": "sdfsdfasdfsdfadsfasd" }, "__typename": "MessageContentPattern" }, "__typename": "sdfdsfdsfsdfdCardDefaultLayoutPattern" }, "__typename": "sdfdsfdsfsdfdCard" }, "__typename": "HomesdfdsfdsfsdfdCard" }, "__typename": "HomeComponents" }, "hasError": false }; var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.cloneDeep(MyObject);
Native structuredClone
myCopy = structuredClone(MyObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Native structuredClone
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/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash cloneDeep
29748.3 Ops/sec
Native structuredClone
36932.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're trying to analyze some benchmarking data, but there's not much of it provided. However, based on the context and what is available: 1. You have two main objects or arrays to work with: `MyObject` (which we don't see explicitly here) and its clones (`myCopy`) using two different methods: Lodash `cloneDeep` and the native `structuredClone`. 2. The benchmark results show execution rates (`ExecutionsPerSecond`) for each method, which can be used to compare their performance. Given this information, I'll provide a neutral, step-by-step answer that doesn't require much context or additional data: ### Step 1: Analyze Lodash `cloneDeep` Performance - **Understanding**: The execution rate of Lodash's `cloneDeep` function is approximately 12389.126953125 executions per second. ### Step 2: Analyze Native `structuredClone` Performance - **Understanding**: The execution rate of the native `structuredClone` method is around 11879.443359375 executions per second. ### Step 3: Compare Performances Both methods seem to perform within a similar range, with the Lodash method being slightly faster in this particular benchmark. However, without knowing the specifics of the data being cloned (like its size and complexity), it's hard to definitively say which is better. ### Step 4: Conclusion - **Lodash `cloneDeep`**: Offers performance slightly above the native `structuredClone`, making it a viable choice for cloning deep JavaScript objects when speed matters. - **Native `structuredClone`**: Provides a standardized, built-in method for cloning data structures in modern browsers. Its usage might be more convenient and safer than using Lodash. Without knowing more about your project's requirements (like the size of data being cloned or any specific constraints on the tools available), it's difficult to make a definitive recommendation between these two methods. In general, if you're working with modern web technologies and can rely on the browser's native support for `structuredClone`, that might be the better choice for performance and simplicity. However, if speed is critical and Lodash's features are essential for your project, using its `cloneDeep` method could be more suitable.
Related benchmarks:
Object Clone Lodash vs structuredClone
Lodash cloneDeep vs structuredClone vs JSON.stringify (small object)
Lodash cloneDeep vs structuredClone vs JSON-JSON
Lodash cloneDeep vs structuredClone 2asdasdas
Lodash cloneDeep vs structuredClone 2asdasdasrgdfg
Comments
Confirm delete:
Do you really want to delete benchmark?