Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Deep clone comparison
(version: 0)
Comparing performance of:
Lodash.cloneDeep() vs jQuery.extend(true)
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js" integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Tests:
Lodash.cloneDeep()
const arr1 = [ true, 1, "true", [], {}, function () {} ]; // Deep copies: true, 1, "true", [], {}, function () {} const arr2 = _.cloneDeep(arr1);
jQuery.extend(true)
const arr1 = [ true, 1, "true", [], {}, function () {} ]; // Deep copies: true, 1, "true", [], {}, function () {} const arr2 = jQuery.extend(true, [], arr1);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash.cloneDeep()
jQuery.extend(true)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser/OS:
Firefox 133 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash.cloneDeep()
2006082.9 Ops/sec
jQuery.extend(true)
1793525.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks! The provided JSON represents two benchmark test cases: "Deep clone comparison" and its individual test cases, "Lodash.cloneDeep()" and "jQuery.extend(true)". **What is being tested?** These benchmarks aim to compare the performance of two methods for creating deep copies of an object in JavaScript: 1. **Lodash.cloneDeep()**: a function from the popular utility library Lodash. 2. **jQuery.extend(true)**: a method from the jQuery library, specifically designed to create deep copies. **Options compared** The benchmarks compare the execution time and performance of these two methods, which can be considered as different approaches: 1. **Lodash.cloneDeep()**: uses a recursive approach with multiple checks for different types of objects (arrays, objects, etc.) to ensure accurate deep copying. 2. **jQuery.extend(true)**: modifies the original object by assigning it a new property with the modified value. **Pros and Cons** **Lodash.cloneDeep():** Pros: * More comprehensive and flexible method for creating deep copies * Handles various data types (arrays, objects, etc.) accurately * Often used in larger applications where deep copying is necessary Cons: * May be slower due to its recursive nature and multiple checks * Requires importing the Lodash library, which may add overhead **jQuery.extend(true):** Pros: * Faster execution time due to its optimized implementation for deep copying * Lightweight and easy to use Cons: * Less comprehensive than Lodash.cloneDeep() and only handles a specific type of data (objects) * Modifies the original object, which might not be desirable in all cases **Other considerations:** 1. **Memory allocation**: Both methods create new objects for deep copying. However, jQuery.extend(true) may allocate less memory due to its optimized implementation. 2. **Readability and maintainability**: Lodash.cloneDeep() is often considered more readable and maintainable due to its explicit checks for different data types. **Library explanations** 1. **Lodash.js**: a popular utility library providing various functions for tasks like array manipulation, object creation, and more. 2. **jQuery**: a widely-used JavaScript library for DOM manipulation and event handling, also offering an extend method for creating deep copies. **Special JS feature or syntax: none mentioned in this benchmark** Now that you know what's being tested and compared, you can better understand the trade-offs between these two methods when it comes to deep cloning objects in JavaScript.
Related benchmarks:
Deep copy comparison
mergeWith lodash vs immutable
Cloning benchmarking (with anonymous functions)
Deep copy comparison with structuredClone
Comments
Confirm delete:
Do you really want to delete benchmark?