Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash cloneDeep vs JSON Clone vs Ramda Clone vs Pvorb Clone Corrected
(version: 0)
Comparing performance of:
Lodash cloneDeep vs Json clone vs Ramda clone vs Pvorb Clone
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 src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/clone/2.1.2/clone.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...' } }; var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.cloneDeep(MyObject);
Json clone
myCopy = JSON.parse(JSON.stringify(MyObject));
Ramda clone
myCopy = R.clone(MyObject);
Pvorb Clone
myCopy = clone(MyObject, false);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Json clone
Ramda clone
Pvorb Clone
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.1:latest
, generated one year ago):
Let's dive into the details of this benchmark test. **What is being tested?** The test case is comparing the performance of four different methods for creating a deep copy of an object in JavaScript: 1. `_.cloneDeep` from Lodash 2. Using `JSON.parse(JSON.stringify(object))` 3. `R.clone` from Ramda 4. `clone` function from Pvorb (a library that provides clone functionality) **Options being compared** The test case is comparing the execution time of each method, measured in executions per second. The goal is to determine which method is the fastest. **Pros and cons of each approach** 1. **Lodash's _.cloneDeep**: * Pros: A dedicated deep cloning function that handles nested objects and arrays. * Cons: Requires Lodash library to be loaded. 2. **JSON.parse(JSON.stringify(object))**: * Pros: A simple, built-in solution using standard JavaScript methods. * Cons: May not work correctly with circular references or non-serializable data types. 3. **Ramda's R.clone**: * Pros: Another dedicated deep cloning function that handles nested objects and arrays. * Cons: Requires Ramda library to be loaded. 4. **Pvorb's clone** (with `false` as the second argument): * Pros: A lightweight, non-recursive implementation. * Cons: May not work correctly with circular references. **Other considerations** * The test case uses a specific object (`MyObject`) and measures the performance of each method in creating a copy of it. * The results are provided for a Chrome 84 browser on a desktop platform (Mac OS X 10.15.6). **Library usage** * **Lodash**: A popular JavaScript utility library that provides many useful functions, including `_.cloneDeep`. * **Ramda**: Another popular JavaScript utility library that provides functional programming helpers, including `R.clone`. * **Pvorb**: A lightweight JavaScript library that provides clone functionality (likely a non-recursive implementation). **JavaScript feature or syntax used** None are explicitly mentioned in the test case. However, the use of `_.cloneDeep`, `JSON.parse(JSON.stringify(object))`, and `R.clone` implies some familiarity with these functions. **Alternative approaches** Other ways to create a deep copy of an object include: * Using a recursive function * Implementing a non-recursive clone algorithm (like Pvorb's) * Utilizing a library like Immutable.js or Mori Keep in mind that this test case focuses on the performance comparison of specific libraries and methods, rather than exploring alternative approaches.
Related benchmarks:
Lodash cloneDeep vs JSON Clone vs Ramda Clone vs Pvorb Clone - Fixed
Lodash cloneDeep vs JSON Clone vs Ramda Clone test
Lodash cloneDeep vs JSON Clone vs Ramda Clone vs Pvorb Clonesdsd
Lodash cloneDeep vs JSON Clone vs Ramda Clone vs Pvorb Cloneaaaaaaaaaaaaaaaaaaaaaaaaaa
Comments
Confirm delete:
Do you really want to delete benchmark?