Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash cloneDeep VS spread operator cart cart
(version: 0)
Comparing performance of:
Lodash cloneDeep vs Spread operator
Created:
4 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 = { "cart": { "token": "987207893750754", "user_id": null, "has_special_promotion": false, "discount_volume_percentage": 0, "has_paypal_promotion": null, "total_products": 1, "value": { "total": 899.0, "discount": 0, "sub_total": 899.0, "grand_total": 899, "coupon_code": null, "coupon_value": 0, "credits_used": 0, "reward_credits": 0, "reward_code": null, "gift_card_credits": 0, "total_discount": 0, "discount_percent": 0, "msi": [ 1, 3 ] }, "products": [ { "product_child_id": 1, "product_parent_id": 1, "product_child_slug": "almohada-r", "category_id": 1, "category_slug": "almohada", "name": "Almohada Regular", "sku": "AL1002", "size": "regular", "price": 899, "special_price": 0, "subtotal": 899, "discount": 0, "color": "default", "quantity": 1, "address_id": 0, "images": [ { "order": 1, "original": "/products/almohada-ajustable-1.jpg", "large": "/products/almohada-ajustable-1.jpg", "medium": "/products/almohada-ajustable-1.jpg", "small": "/products/almohada-ajustable-1.jpg" }, { "order": 2, "original": "/products/almohada-ajustable-2.jpg", "large": "/products/almohada-ajustable-2.jpg", "medium": "/products/almohada-ajustable-2.jpg", "small": "/products/almohada-ajustable-2.jpg" }, { "order": 3, "original": "/products/almohada-ajustable-3.jpg", "large": "/products/almohada-ajustable-3.jpg", "medium": "/products/almohada-ajustable-3.jpg", "small": "/products/almohada-ajustable-3.jpg" }, { "order": 4, "original": "/products/almohada-ajustable-4.jpg", "large": "/products/almohada-ajustable-4.jpg", "medium": "/products/almohada-ajustable-4.jpg", "small": "/products/almohada-ajustable-4.jpg" }, { "order": 5, "original": "/products/almohada-ajustable-5.jpg", "large": "/products/almohada-ajustable-5.jpg", "medium": "/products/almohada-ajustable-5.jpg", "small": "/products/almohada-ajustable-5.jpg" } ], "is_free": false, "promotions": [] }, { "product_child_id": 8, "product_parent_id": 8, "product_child_slug": "set-sabanas-individual-blanco", "category_id": 3, "category_slug": "sabana", "name": "Set Sábanas Individual Blanco", "sku": "SH131", "size": "twin", "price": 1690, "special_price": 0, "subtotal": 1690, "discount": 0, "color": "blanco", "quantity": 1, "address_id": 0, "images": [ { "order": 1, "original": "/products/new-set-sabana-blanco-full-large.jpg", "large": "/products/new-set-sabana-blanco-full-large.jpg", "medium": "/products/new-set-sabana-blanco-full-large.jpg", "small": "/products/new-set-sabana-blanco-full-large.jpg" }, { "order": 2, "original": "/products/new-set-sabana-blanco-full-large-2.png", "large": "/products/new-set-sabana-blanco-full-large-2.png", "medium": "/products/new-set-sabana-blanco-full-large-2.png", "small": "/products/new-set-sabana-blanco-full-large-2.png" }, { "order": 3, "original": "/products/new-set-sabana-blanco-full-large-3.png", "large": "/products/new-set-sabana-blanco-full-large-3.png", "medium": "/products/new-set-sabana-blanco-full-large-3.png", "small": "/products/new-set-sabana-blanco-full-large-3.png" }, { "order": 4, "original": "/products/new-set-sabana-blanco-full-large-4.png", "large": "/products/new-set-sabana-blanco-full-large-4.png", "medium": "/products/new-set-sabana-blanco-full-large-4.png", "small": "/products/new-set-sabana-blanco-full-large-4.png" } ], "is_free": false, "promotions": [] }, { "product_child_id": 12, "product_parent_id": 12, "product_child_slug": "colchon-regular", "category_id": 93, "category_slug": "colchon", "name": "Colchón Individual", "sku": "LAG354", "size": "twin", "price": 7599, "special_price": 7599, "subtotal": 7599, "discount": 0, "color": "default", "quantity": 1, "address_id": 0, "images": [ { "order": 1, "original": "/products/new-colchon-luuna-1.png", "large": "/products/new-colchon-luuna-1.png", "medium": "/products/new-colchon-luuna-1.png", "small": "/products/new-colchon-luuna-1.png" }, { "order": 2, "original": "/products/new-colchon-luuna-2.png", "large": "/products/new-colchon-luuna-2.png", "medium": "/products/new-colchon-luuna-2.png", "small": "/products/new-colchon-luuna-2.png" }, { "order": 3, "original": "/products/new-colchon-luuna-3.jpg", "large": "/products/new-colchon-luuna-3.jpg", "medium": "/products/new-colchon-luuna-3.jpg", "small": "/products/new-colchon-luuna-3.jpg" }, { "order": 4, "original": "/products/new-colchon-luuna-4.jpg", "large": "/products/new-colchon-luuna-4.jpg", "medium": "/products/new-colchon-luuna-4.jpg", "small": "/products/new-colchon-luuna-4.jpg" } ], "is_free": false, "promotions": [] } ], "cross_selling": [ { "id": 6, "name": "Colchón King", "price": 10, "special_price": 17990.0, "image": "/products/new-colchon-luuna-1.png" } ], "suggest": [ { "percentage": 10, "product_id": 1, "quantity": 1, "message": "Aumenta 1 Almohadas y obten un 10% adicional en tus almohadas." } ] } }; var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.cloneDeep(MyObject);
Spread operator
myCopy = {...MyObject};
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Spread operator
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):
To answer this question, I'll focus on the data provided and extract relevant information for each test case. **Test Case 1: Lodash `cloneDeep`** From the latest benchmark result: ```json { "RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36", "Browser": "Chrome 94", "DevicePlatform": "Desktop", "OperatingSystem": "Mac OS X 10.15.7", "ExecutionsPerSecond": 69247.5078125, "TestName": "Lodash cloneDeep" } ``` **Performance Analysis:** * The benchmark result shows that `Chrome 94` on a `Mac OS X 10.15.7` desktop executed the `Lodash `cloneDeep`` test case approximately 69247 times per second. * This suggests that the Lodash `cloneDeep` function is relatively fast, with an execution rate comparable to other benchmark results. **Test Case 2: Spread Operator** From the latest benchmark result: ```json { "RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36", "Browser": "Chrome 94", "DevicePlatform": "Desktop", "OperatingSystem": "Mac OS X 10.15.7", "ExecutionsPerSecond": 10555645.0, "TestName": "Spread operator" } ``` **Performance Analysis:** * The benchmark result shows that `Chrome 94` on a `Mac OS X 10.15.7` desktop executed the spread operator test case approximately 10555645 times per second. * This suggests that the spread operator is faster than the Lodash `cloneDeep` function, with an execution rate significantly higher. **Conclusion:** Based on the latest benchmark results, it appears that the spread operator outperforms the Lodash `cloneDeep` function in terms of execution speed. The spread operator's superior performance may be attributed to its simplicity and lack of dependencies on external libraries like Lodash.
Related benchmarks:
cloneDeep vs spread object
map vs reduce cart items
cloneDeep vs spread object vs json
Object.keys partial assign vs Spread Operator
Comments
Confirm delete:
Do you really want to delete benchmark?