Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
CloneDeep or CloneObject or Clone or CloneVanilla
(version: 0)
Comparing performance of:
Lodash cloneDeep vs Lodash clone vs CloneVanilla vs CloneObject
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 = [ { "_id": "66e7eff9116f8e690a42def7", "index": 0, "guid": "daad7d80-1097-44c6-b914-bab27c62a254", "isActive": true, "balance": "$2,505.86", "picture": "http://placehold.it/32x32", "age": 30, "eyeColor": "green", "name": "Browning Shields", "gender": "male", "company": "BUZZNESS", "email": "browningshields@buzzness.com", "phone": "+1 (907) 513-2282", "address": "626 Seaview Court, Trexlertown, Ohio, 6495", "about": "Incididunt quis ea ipsum elit reprehenderit minim sunt. Do laboris minim voluptate mollit labore non ea amet ipsum sint culpa sunt sunt laboris. Id cillum amet laborum reprehenderit commodo reprehenderit in nulla proident. Voluptate non irure ex velit ex exercitation amet eiusmod magna nostrud do ea ut. Mollit duis ad ipsum Lorem ex enim in adipisicing exercitation ea. Lorem laborum magna est esse anim voluptate dolor aliquip voluptate voluptate duis commodo quis proident. Amet duis irure elit officia.\r\n", "registered": "2021-11-01T04:00:26 -01:00", "latitude": -84.115826, "longitude": 125.358871, "tags": [ "veniam", "nostrud", "eu", "qui", "eu", "commodo", "ullamco" ], "friends": [ { "id": 0, "name": "Dona Watts" }, { "id": 1, "name": "Mae Cantu" }, { "id": 2, "name": "Dillon Fry" } ], "greeting": "Hello, Browning Shields! You have 10 unread messages.", "favoriteFruit": "banana" }, { "_id": "66e7eff92b6ca402ad7ab8bd", "index": 1, "guid": "8b628d39-9fff-4d28-b4c5-35bc003a88cc", "isActive": true, "balance": "$2,299.78", "picture": "http://placehold.it/32x32", "age": 20, "eyeColor": "blue", "name": "Dunlap Hubbard", "gender": "male", "company": "IRACK", "email": "dunlaphubbard@irack.com", "phone": "+1 (938) 440-3887", "address": "514 Fulton Street, Oasis, Guam, 2302", "about": "Aute veniam irure est laboris consequat nostrud tempor culpa aliqua ex in exercitation sint ipsum. Ipsum culpa magna est laboris consequat ipsum consequat ullamco fugiat elit. In voluptate ex fugiat consequat in ipsum proident reprehenderit nostrud irure ea nulla esse ex. Velit adipisicing cupidatat cillum aute sint occaecat. Amet elit elit voluptate occaecat elit in adipisicing minim id veniam. Do occaecat laborum dolore pariatur enim deserunt ex reprehenderit in irure.\r\n", "registered": "2021-10-18T03:34:17 -02:00", "latitude": 26.597269, "longitude": -93.956704, "tags": [ "nulla", "cillum", "reprehenderit", "Lorem", "laboris", "consequat", "non" ], "friends": [ { "id": 0, "name": "Mccoy Kent" }, { "id": 1, "name": "Josefina Carlson" }, { "id": 2, "name": "Angeline Soto" } ], "greeting": "Hello, Dunlap Hubbard! You have 6 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "66e7eff9de2dc4dd45378184", "index": 2, "guid": "ac90092e-c051-4aeb-9475-f8e0dd72d796", "isActive": false, "balance": "$1,097.89", "picture": "http://placehold.it/32x32", "age": 34, "eyeColor": "brown", "name": "Sharpe Salazar", "gender": "male", "company": "EXOSWITCH", "email": "sharpesalazar@exoswitch.com", "phone": "+1 (999) 510-2988", "address": "425 Etna Street, Noblestown, Nevada, 1156", "about": "Nisi ex mollit do anim reprehenderit quis ad. Labore culpa occaecat Lorem elit labore. Qui aute tempor duis excepteur ea enim est eu voluptate non proident cupidatat enim nisi. Commodo ut non ullamco fugiat qui elit aliqua ipsum cillum occaecat amet. Excepteur nulla dolor sint culpa laborum cupidatat non sunt.\r\n", "registered": "2017-01-24T11:40:29 -01:00", "latitude": -84.888941, "longitude": 148.555312, "tags": [ "nostrud", "fugiat", "aliqua", "officia", "culpa", "cupidatat", "excepteur" ], "friends": [ { "id": 0, "name": "Dorthy Cameron" }, { "id": 1, "name": "Geneva Adkins" }, { "id": 2, "name": "Chambers Mcneil" } ], "greeting": "Hello, Sharpe Salazar! You have 8 unread messages.", "favoriteFruit": "apple" }, { "_id": "66e7eff9f81fd8fa54937393", "index": 3, "guid": "e11a6b70-4b2c-4403-a325-f0962b93d8d3", "isActive": true, "balance": "$3,010.86", "picture": "http://placehold.it/32x32", "age": 31, "eyeColor": "green", "name": "Roberta Hayden", "gender": "female", "company": "DIGIFAD", "email": "robertahayden@digifad.com", "phone": "+1 (910) 446-3209", "address": "874 Leonora Court, Omar, Nebraska, 1799", "about": "Ex quis do sunt duis eu aliqua deserunt. Sint cillum amet cupidatat aliqua sunt amet enim. Ut laboris ipsum mollit exercitation velit consequat commodo amet amet mollit. Cupidatat pariatur Lorem Lorem fugiat enim do. Cupidatat ut aliquip dolore consectetur eiusmod in sint. Ad labore culpa consequat non exercitation dolore ut sit qui sunt nostrud voluptate. Nisi eiusmod eu commodo in irure cupidatat culpa cupidatat aliquip et consequat.\r\n", "registered": "2020-09-18T04:47:32 -02:00", "latitude": 16.103599, "longitude": -26.524586, "tags": [ "aliquip", "anim", "laboris", "commodo", "ipsum", "Lorem", "nisi" ], "friends": [ { "id": 0, "name": "Lela Holder" }, { "id": 1, "name": "Robinson Carney" }, { "id": 2, "name": "Mcintosh Clayton" } ], "greeting": "Hello, Roberta Hayden! You have 2 unread messages.", "favoriteFruit": "banana" }, { "_id": "66e7eff9833dea3a5ca1d935", "index": 4, "guid": "8633a0f8-51c7-4019-bb15-d9399b4de8c0", "isActive": true, "balance": "$3,574.84", "picture": "http://placehold.it/32x32", "age": 24, "eyeColor": "green", "name": "Fields Mcpherson", "gender": "male", "company": "HAIRPORT", "email": "fieldsmcpherson@hairport.com", "phone": "+1 (822) 569-2216", "address": "326 Chestnut Avenue, Singer, New Jersey, 3427", "about": "Quis anim aliqua ullamco duis. Reprehenderit mollit nulla mollit officia ullamco sunt. Eu sunt proident commodo non. Non dolore proident culpa anim nostrud occaecat magna aute qui eiusmod sunt proident. Pariatur incididunt ipsum cillum incididunt proident minim reprehenderit officia.\r\n", "registered": "2018-09-02T09:23:44 -02:00", "latitude": 52.577334, "longitude": -41.082569, "tags": [ "laboris", "ea", "cillum", "quis", "cillum", "aliquip", "consectetur" ], "friends": [ { "id": 0, "name": "Santos Higgins" }, { "id": 1, "name": "Bauer Russo" }, { "id": 2, "name": "Drake Dickerson" } ], "greeting": "Hello, Fields Mcpherson! You have 4 unread messages.", "favoriteFruit": "apple" } ]; var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.cloneDeep(MyObject);
Lodash clone
myCopy = _.clone(MyObject);
CloneVanilla
function clone(obj) { const clone = Object.create(Object.getPrototypeOf(obj)); Object.getOwnPropertyNames(obj).forEach(key => { Object.defineProperty(clone, key, Object.getOwnPropertyDescriptor(obj, key)); }); return clone; } myCopy = clone(MyObject);
CloneObject
function clone(obj) { let result = {}; result = JSON.parse(JSON.stringify(obj)); return result; } myCopy = clone(MyObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Lodash clone
CloneVanilla
CloneObject
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/126.0.0.0 Safari/537.36
Browser/OS:
Chrome 126 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash cloneDeep
70220.2 Ops/sec
Lodash clone
6452884.0 Ops/sec
CloneVanilla
565809.8 Ops/sec
CloneObject
65910.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're providing a detailed benchmarking result with various test cases, including Lodash's `cloneDeep`, `clone`, and vanilla clone functions, along with another test case that uses JSON serialization. To provide a helpful response, I'll focus on extracting the relevant information from the benchmark results. The latest benchmark results show that: 1. **Lodash clone**: The fastest execution time is approximately 565809.8125 executions per second. 2. **CloneVanilla**: The fastest execution time is approximately 70220.1953125 executions per second. 3. **Lodash cloneDeep**: The fastest execution time is approximately 65910.7734375 executions per second. 4. **CloneObject**: The fastest execution time is not explicitly shown, but it's likely slower than Lodash clone and CloneVanilla. Based on the results, if you're looking for a fast and efficient way to clone objects in JavaScript, using Lodash's `cloneDeep` function seems to be the best option, with an average of around 659 executions per second. However, please note that this result may vary depending on your specific use case and environment. If you'd like me to provide further insights or suggestions, feel free to ask!
Related benchmarks:
Lodash cloneDeep vs JSON Clone (Large Object)
Lodash cloneDeep vs JSON Clone (Large Object 2)
Lodash cloneDeep vs JSON Clone Large object
Large JSON - Lodash CloneDeep vs JSON Stringify/Parse
Lodash(v4.17.21) cloneDeep vs JSON Clone Larger object
Comments
Confirm delete:
Do you really want to delete benchmark?