Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash cloneDeep vs Custom Recursive cloneDeep
(version: 1)
https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
Comparing performance of:
Lodash cloneDeep vs Custom Recursive cloneDeep
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:
var MyObject = { description: 'Creates a deep copy of source, which should be an object or an array.', myNumber: 123456789, myBoolean: true, jayson: { stringify: 'JSON.stringify() method converts a JavaScript value to a JSON string....', parse: 'JSON.parse() method parses a JSON string...' } }; function cloneDeep(obj) { if (obj === null || typeof obj !== 'object') { return obj } if (obj instanceof Date) { return new Date(obj) } if (obj instanceof RegExp) { return new RegExp(obj) } if (Array.isArray(obj)) { return obj.map(v => cloneDeep(v)) } const clonedObj = {} for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { clonedObj[key] = cloneDeep(obj[key]) } } return clonedObj } var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.cloneDeep(MyObject);
Custom Recursive cloneDeep
myCopy = cloneDeep(MyObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Custom Recursive cloneDeep
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash cloneDeep
1188744.0 Ops/sec
Custom Recursive cloneDeep
4809771.0 Ops/sec
Related benchmarks:
Lodash cloneDeep vs structuredClone vs recursiveDeepCopy vs JSON clone
Lodash cloneDeep vs structuredClone vs recursiveDeepCopy vs JSON clone vs Fast Copy
Lodash cloneDeep vs structuredClone vs cloneObject (custom func)
lodash clonedeep vs json.parse(stringify()) vs structuredClone
lodash clonedeep vs json.parse(stringify()) vs recursive copy vs structuredClone (list of 150 elements)
Lodash cloneDeep vs structuredClone vs JSON-JSON
Lodash cloneDeep vs structuredClone vs recursiveDeepCopy vs JSON clone with a more deep test
Lodash cloneDeep vs structuredClone vs recursiveDeepCopy vs JSON clone with a simple and a more deep test
lodash clonedeep vs json.parse(stringify()) vs recursivecopy vs structured clone
Comments
Confirm delete:
Do you really want to delete benchmark?