Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RFDC clone (circles: true) vs Lodash cloneDeep vs JSON Clone
(version: 0)
Comparing performance of:
Lodash cloneDeep vs Json clone vs RFDC copy
Created:
3 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 = _.cloneDeep(sampleObject);
Json clone
myCopy = JSON.parse(JSON.stringify(sampleObject));
RFDC copy
var clone = rfdc({ circles: true }); 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 is being tested. **Benchmark Definition** The benchmark is testing three different approaches to cloning an object in JavaScript: 1. `RFDC copy` (using the `rfdc` library): This approach uses a library that provides a way to create deep copies of objects. 2. `Lodash cloneDeep`: This approach uses the `lodash` library's `cloneDeep` function to create a deep copy of an object. 3. `JSON Clone`: This approach uses the built-in `JSON.parse(JSON.stringify(obj))` method to create a shallow copy of an object. **What is being tested?** The benchmark is testing which approach can create the fastest, most efficient clone of the input object. **Options Comparison** Here's a brief comparison of the three approaches: 1. **RFDC Copy**: * Pros: Can handle complex objects with nested arrays and objects. * Cons: Requires an additional library (rfdc) to be included in the test environment. 2. **Lodash CloneDeep**: * Pros: Well-tested and widely used library for deep cloning objects. * Cons: May have performance overhead due to its complexity. 3. **JSON Clone**: * Pros: Built-in method, no additional libraries required. * Cons: Only creates a shallow copy of the object, which may not be sufficient for all use cases. **Library and Purpose** * `rfdc`: A library that provides a way to create deep copies of objects in JavaScript. It's designed to handle complex objects with nested arrays and objects. * `lodash`: A popular utility library that provides various functional programming helpers, including the `cloneDeep` function for deep cloning objects. **Other Considerations** When choosing an approach, consider the following factors: * Performance: How fast does each approach need to be? * Complexity: What level of complexity can each approach handle? * Memory usage: How much memory will each approach allocate for the cloned object? Ultimately, the choice of approach depends on the specific requirements of your application. **Benchmark Results** The latest benchmark results show that: 1. `RFDC Copy` is the fastest approach, with an average execution speed of 182694.578125 executions per second. 2. `Lodash CloneDeep` is slower than `RFDC Copy`, but still relatively fast, with an average execution speed of 86495.6328125 executions per second. 3. `JSON Clone` is the slowest approach, with an average execution speed of 49079.59765625 executions per second. Please note that these results may vary depending on the specific test environment and hardware being used.
Related benchmarks:
RFDC clone vs Lodash cloneDeep vs JSON Parse
RFDC clone vs Lodash clone vs JSON Clone
RFDC clone vs clone-deep clone vs Lodash cloneDeep vs JSON Clone
RFDC clone vs Clone vs JSON Clone
Comments
Confirm delete:
Do you really want to delete benchmark?