Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash cloneDeep vs JSON Clone (BIG OBJECT)
(version: 0)
Comparing performance of:
Lodash cloneDeep big object vs Json clone big object
Created:
6 years 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:
var MyObject = { "web-app": { "servlet": [ { "servlet-name": "cofaxCDS", "servlet-class": "org.cofax.cds.CDSServlet", "init-param": { "configGlossary:installationAt": "Philadelphia, PA", "configGlossary:adminEmail": "ksm@pobox.com", "configGlossary:poweredBy": "Cofax", "configGlossary:poweredByIcon": "/images/cofax.gif", "configGlossary:staticPath": "/content/static", "templateProcessorClass": "org.cofax.WysiwygTemplate", "templateLoaderClass": "org.cofax.FilesTemplateLoader", "templatePath": "templates", "templateOverridePath": "", "defaultListTemplate": "listTemplate.htm", "defaultFileTemplate": "articleTemplate.htm", "useJSP": false, "jspListTemplate": "listTemplate.jsp", "jspFileTemplate": "articleTemplate.jsp", "cachePackageTagsTrack": 200, "cachePackageTagsStore": 200, "cachePackageTagsRefresh": 60, "cacheTemplatesTrack": 100, "cacheTemplatesStore": 50, "cacheTemplatesRefresh": 15, "cachePagesTrack": 200, "cachePagesStore": 100, "cachePagesRefresh": 10, "cachePagesDirtyRead": 10, "searchEngineListTemplate": "forSearchEnginesList.htm", "searchEngineFileTemplate": "forSearchEngines.htm", "searchEngineRobotsDb": "WEB-INF/robots.db", "useDataStore": true, "dataStoreClass": "org.cofax.SqlDataStore", "redirectionClass": "org.cofax.SqlRedirection", "dataStoreName": "cofax", "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", "dataStoreUser": "sa", "dataStorePassword": "dataStoreTestQuery", "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", "dataStoreInitConns": 10, "dataStoreMaxConns": 100, "dataStoreConnUsageLimit": 100, "dataStoreLogLevel": "debug", "maxUrlLength": 500 } }, { "servlet-name": "cofaxEmail", "servlet-class": "org.cofax.cds.EmailServlet", "init-param": { "mailHost": "mail1", "mailHostOverride": "mail2" } }, { "servlet-name": "cofaxAdmin", "servlet-class": "org.cofax.cds.AdminServlet" }, { "servlet-name": "fileServlet", "servlet-class": "org.cofax.cds.FileServlet" }, { "servlet-name": "cofaxTools", "servlet-class": "org.cofax.cms.CofaxToolsServlet", "init-param": { "templatePath": "toolstemplates/", "log": 1, "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", "logMaxSize": "", "dataLog": 1, "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", "dataLogMaxSize": "", "removePageCache": "/content/admin/remove?cache=pages&id=", "removeTemplateCache": "/content/admin/remove?cache=templates&id=", "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", "lookInContext": 1, "adminGroupID": 4, "betaServer": true } } ], "servlet-mapping": { "cofaxCDS": "/", "cofaxEmail": "/cofaxutil/aemail/*", "cofaxAdmin": "/admin/*", "fileServlet": "/static/*", "cofaxTools": "/tools/*" }, "taglib": { "taglib-uri": "cofax.tld", "taglib-location": "/WEB-INF/tlds/cofax.tld" } } }; var myCopy = null;
Tests:
Lodash cloneDeep big object
myCopy = _.cloneDeep(MyObject);
Json clone big object
myCopy = JSON.parse(JSON.stringify(MyObject));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash cloneDeep big object
Json clone big object
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):
Let's break down the benchmark and explain what is being tested. **Benchmark Definition** The benchmark is created using two JavaScript functions: `_.cloneDeep` from Lodash and `JSON.parse(JSON.stringify)` (also known as "JSON cloning"). **Options Being Compared** There are two options being compared: 1. **Lodash cloneDeep**: This function creates a deep copy of the input object, which means it recursively clones all nested objects and arrays. 2. **JSON Clone**: This method uses `JSON.parse(JSON.stringify)` to create a shallow copy of the input object. **Pros and Cons** * **Lodash cloneDeep**: + Pros: Can handle complex data structures with nested objects and arrays, provides more control over the cloning process. + Cons: Can be slower than JSON Clone due to its recursive nature. * **JSON Clone**: + Pros: Fast and lightweight, suitable for simple data structures. + Cons: Only works for shallow copying (i.e., does not recursively clone nested objects and arrays). **Library and Purpose** The Lodash library is a popular JavaScript utility library that provides various functional programming helpers, including the `cloneDeep` function. **Special JS Feature or Syntax** None mentioned in this benchmark. However, it's worth noting that some browsers may have specific optimizations or limitations for certain built-in functions like `JSON.parse(JSON.stringify)`. **Test Cases** The individual test cases are: 1. **Lodash cloneDeep big object**: This test case uses the `_.cloneDeep` function to create a deep copy of the input object (`MyObject`) and assigns it to a new variable (`myCopy`). 2. **JSON Clone big object**: This test case uses the `JSON.parse(JSON.stringify)` method to create a shallow copy of the input object (`MyObject`) and assigns it to a new variable (`myCopy`). **Benchmark Result** The latest benchmark result shows that the JSON Clone method outperforms Lodash cloneDeep for this specific use case. However, it's essential to note that performance can vary depending on the size and complexity of the input data. Overall, this benchmark helps users choose between two popular methods for cloning JavaScript objects: the lightweight but shallow `JSON.parse(JSON.stringify)` method or the more robust but potentially slower Lodash cloneDeep function.
Related benchmarks:
Lodash3 cloneDeep vs JSON Clone (BIG OBJECT)
Lodash cloneDeep vs JSON Clone big object 12345
Lodash cloneDeep vs clone vs spread
Lodash cloneDeep vs JSON Clone vs freeze and get - access a value
Comments
Confirm delete:
Do you really want to delete benchmark?