Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash clonedeep vs json.parse(stringify()) vs recursivecopy v2
(version: 0)
Comparing performance of:
Lodash CloneDeep vs Json Clone vs recursiveDeepCopy
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 = { "list": { "0oVwOM": { "id": "0oVwOM", "parent": "pTlmbh", "name": "New node", "created_at": 1384289621 }, "aHxe8k": { "id": "aHxe8k", "parent": "Fhs2hL", "name": "hjkhjkhjk", "created_at": 1384354593 }, "Fhs2hL": { "id": "Fhs2hL", "parent": "root", "name": "test", "created_at": 1383403881 }, "HYPSgv": { "id": "HYPSgv", "parent": "0oVwOM", "name": "New node", "created_at": 1384342657 }, "osFIMf": { "id": "osFIMf", "parent": "root", "name": "New node", "created_at": 1384354584 }, "PsovXE": { "id": "PsovXE", "parent": "root", "name": "hjkhjkhjk", "created_at": 1384354589 }, "pTlmbh": { "id": "pTlmbh", "parent": "Fhs2hL", "name": "New node", "created_at": 1384289277 }, "RbXhdJ": { "id": "RbXhdJ", "parent": "root", "name": "empty", "created_at": 1384359806 } }, "maps": { "parent": { "pTlmbh": { "0oVwOM": { "id": "0oVwOM", "parent": "pTlmbh", "name": "New node", "created_at": 1384289621 } }, "Fhs2hL": { "aHxe8k": { "id": "aHxe8k", "parent": "Fhs2hL", "name": "hjkhjkhjk", "created_at": 1384354593 }, "pTlmbh": { "id": "pTlmbh", "parent": "Fhs2hL", "name": "New node", "created_at": 1384289277 } }, "root": { "Fhs2hL": { "id": "Fhs2hL", "parent": "root", "name": "test", "created_at": 1383403881 }, "osFIMf": { "id": "osFIMf", "parent": "root", "name": "New node", "created_at": 1384354584 }, "PsovXE": { "id": "PsovXE", "parent": "root", "name": "hjkhjkhjk", "created_at": 1384354589 }, "RbXhdJ": { "id": "RbXhdJ", "parent": "root", "name": "empty", "created_at": 1384359806 } }, "0oVwOM": { "HYPSgv": { "id": "HYPSgv", "parent": "0oVwOM", "name": "New node", "created_at": 1384342657 } } }, "path": [ ["Fhs2hL"], ["Fhs2hL", "aHxe8k"], ["Fhs2hL", "pTlmbh"], ["Fhs2hL", "pTlmbh", "0oVwOM"], ["Fhs2hL", "pTlmbh", "0oVwOM", "HYPSgv"], ["osFIMf"], ["PsovXE"], ["RbXhdJ"] ] } }; var myCopy = null; function recursiveDeepCopy(o) { var newO, i; if (typeof o !== 'object') { return o; } if (!o) { return o; } if ('[object Array]' === Object.prototype.toString.apply(o)) { newO = []; for (i = 0; i < o.length; i += 1) { newO[i] = recursiveDeepCopy(o[i]); } return newO; } newO = {}; for (i in o) { if (o.hasOwnProperty(i)) { newO[i] = recursiveDeepCopy(o[i]); } } return newO; }
Tests:
Lodash CloneDeep
myCopy = _.cloneDeep(MyObject);
Json Clone
myCopy = JSON.parse(JSON.stringify(MyObject));
recursiveDeepCopy
myCopy = recursiveDeepCopy(MyObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash CloneDeep
Json Clone
recursiveDeepCopy
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 task is to identify the difference in execution speed between three different methods of cloning an object: Lodash's `cloneDeep` function, JSON.parse(JSON.stringify()) method, and a custom recursiveDeepCopy function. To do this, we'll analyze the latest benchmark result and compare the execution speeds of each method for the specific test case "recursiveDeepCopy". The raw UA string indicates that the browser is Chrome 73 on a Windows desktop. The relevant data points from the benchmark result are: * `ExecutionsPerSecond`: 33577.0703125 (for recursiveDeepCopy) * `TestName`: recursiveDeepCopy We can see that recursiveDeepCopy has the highest execution speed among the three methods, with an average of over 33,500 executions per second.
Related benchmarks:
lodash clonedeep vs json.parse(stringify()) vs recursivecopy new big
Lodash cloneDeep vs JSON parse
Object cloning with Lodash clone vs cloneDeep vs merge vs structuredClone vs JSON.parse(JSON.stringify(o))
Object cloning with Lodash clone vs cloneDeep vs merge vs structuredClone vs JSON.parse(JSON.stringify(o)) 2
Comments
Confirm delete:
Do you really want to delete benchmark?