Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RFDC clone vs Lodash clone vs JSON Clone
(version: 0)
Comparing performance of:
Lodash cloneDeep vs Json clone vs RFDC copy
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/rfdc@1.1.4/index.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js"></script>
Script Preparation code:
var sampleObject = [{ "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.55, "batters": { "batter": [{ "id": "1001", "type": "Regular" }, { "id": "1002", "type": "Chocolate" }, { "id": "1003", "type": "Blueberry" }, { "id": "1004", "type": "Devil's Food" } ] }, "topping": [{ "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5005", "type": "Sugar" }, { "id": "5007", "type": "Powdered Sugar" }, { "id": "5006", "type": "Chocolate with Sprinkles" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] }, { "id": "0002", "type": "donut", "name": "Raised", "ppu": 0.55, "batters": { "batter": [{ "id": "1001", "type": "Regular" }] }, "topping": [{ "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5005", "type": "Sugar" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] }, { "id": "0003", "type": "donut", "name": "Old Fashioned", "ppu": 0.55, "batters": { "batter": [{ "id": "1001", "type": "Regular" }, { "id": "1002", "type": "Chocolate" } ] }, "topping": [{ "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] } ]; var myCopy = null;
Tests:
Lodash cloneDeep
myCopy = _.clone(sampleObject);
Json clone
myCopy = JSON.parse(JSON.stringify(sampleObject));
RFDC copy
var clone = rfdc(); myCopy = clone(sampleObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash cloneDeep
Json clone
RFDC copy
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):
Let's break down the benchmark and explain what's being tested. The benchmark compares the performance of three different methods for cloning an object: 1. **Lodash Clone Deep**: This method uses the `cloneDeep` function from Lodash, a popular JavaScript utility library. 2. **JSON Clone**: This method uses the `JSON.parse(JSON.stringify(sampleObject))` syntax to clone the object. 3. **RFDC Copy**: This method uses the `rfdc()` function from the RFDC (Randomized Deep Clone) library. **Lodash Clone Deep** * **Purpose:** Create a deep copy of an object, recursively cloning all nested properties and arrays. * **Pros:** + Provides a simple and efficient way to create a deep clone of an object. + Supports cloning of complex data structures, such as arrays and objects with nested properties. * **Cons:** + Requires the Lodash library to be loaded, which may increase the overall size of the application. + May not be suitable for very large or complex objects due to potential performance issues. **JSON Clone** * **Purpose:** Use JSON serialization to create a deep clone of an object. * **Pros:** + Lightweight and does not require any additional libraries. + Can be useful when working with limited resources or in environments where loading external libraries is not allowed. * **Cons:** + May not work correctly with certain data structures, such as objects with circular references or complex arrays. + Can result in a larger binary payload compared to other methods. **RFDC Copy** * **Purpose:** Create a deep copy of an object using a randomized algorithm that minimizes memory allocation and copying. * **Pros:** + Provides fast performance and is suitable for large objects. + Does not require any additional libraries or dependencies. * **Cons:** + May not be as straightforward to implement as other methods, requiring more development effort. + Requires a good understanding of the underlying algorithm and its trade-offs. In summary, this benchmark compares three different approaches for cloning an object: 1. Lodash Clone Deep: Provides a simple and efficient way to create a deep clone, but requires additional library dependencies. 2. JSON Clone: A lightweight approach that uses JSON serialization, but may not work correctly with all data structures. 3. RFDC Copy: A fast and lightweight algorithm that minimizes memory allocation and copying, but may require more development effort. The benchmark results show the performance characteristics of each method on a specific test case, allowing developers to make informed decisions about which approach to use in their own applications.
Related benchmarks:
RFDC clone vs Lodash cloneDeep vs JSON Clone
RFDC clone vs Lodash cloneDeep vs JSON Parse
RFDC clone vs clone-deep clone vs Lodash cloneDeep vs JSON Clone
RFDC clone (circles: true) vs Lodash cloneDeep vs JSON Clone
Comments
Confirm delete:
Do you really want to delete benchmark?