Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda vs Lodash CloneDeep vs Immer Produce with heavy load
(version: 0)
Comparing performance of:
Produce vs CloneDeep vs Ramda
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/immer@3.1.3/dist/immer.umd.min.js"></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script> <script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
Script Preparation code:
state = { data: { data1: { data2: 'test', }, data3: Array.from({length: 1000}).map(() => document.createElement('div')) } };
Tests:
Produce
const result = immer.produce(state, draft => { draft.data.data1.data2 = 'updated' })
CloneDeep
const result = _.cloneDeep(state); result.data.data1.data2 = 'updated';
Ramda
const result = R.clone(state); result.data.data1.data2 = 'updated';
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Produce
CloneDeep
Ramda
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (iPad; CPU OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) EdgiOS/131.0.2903.145 Version/17.0 Mobile/15E148 Safari/604.1
Browser/OS:
Mobile Safari 17 on iOS 17.7.2
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Produce
385939.8 Ops/sec
CloneDeep
4237.1 Ops/sec
Ramda
4158.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** The provided benchmark measures the performance of three JavaScript libraries: Ramda, Lodash CloneDeep, and Immer Produce, in terms of cloning/deep copying and updating data structures. The benchmark is designed to test these libraries under heavy loads. **Tested Options** The three options being compared are: 1. **Immer Produce**: This library provides a way to produce a new value from an existing one by applying a transformation function to the original value. It's designed for data structures like objects and arrays. 2. **Lodash CloneDeep**: This is a utility library that provides a deep cloning function, `cloneDeep`, which creates a completely independent copy of an object or array, including all nested properties. 3. **Ramda**: A functional programming library that includes various functions for manipulating data structures, such as `clone`. **Pros and Cons** * **Immer Produce**: * Pros: Efficient and concise syntax, optimized for data structures like objects and arrays. Can be faster than other options due to its immutability model. * Cons: May not be suitable for complex or deeply nested data structures, as it can lead to performance issues. * **Lodash CloneDeep**: * Pros: Robust and reliable deep cloning function that handles complex data structures. Can handle cyclic references and other edge cases. * Cons: May introduce unnecessary overhead due to the creation of a new object and the overhead of recursively calling `cloneDeep`. * **Ramda**: * Pros: Provides various functions for manipulating data structures, including `clone`, which can be used for deep copying. Ramda encourages functional programming principles. * Cons: May have performance overhead due to the creation of intermediate values. **Library and Syntax** * **Immer**: A library designed specifically for efficient and immutable data updates. Its syntax is concise and easy to read, making it suitable for large-scale applications. * **Lodash CloneDeep**: As mentioned earlier, this utility library provides a reliable and robust deep cloning function. Its syntax is straightforward and easy to understand. * **Ramda**: This functional programming library includes various functions for manipulating data structures, including `clone`. Ramda's syntax can take some time to get used to, but it encourages a more functional programming approach. **Special Features or Syntax** The benchmark does not explicitly test special features like async/await, promises, or ES6+ syntax. However, the libraries being compared are generally compatible with these modern JavaScript features. **Other Alternatives** For deep cloning and data updates, consider using: * **Immutable.js**: A library that provides a more comprehensive and flexible solution for immutable data structures. * **Duck.js**: Another utility library for functional programming principles and data manipulation. * **JQuery clone**: While not as optimized as Lodash CloneDeep or Ramda's `clone`, jQuery's `$.clone()` method can still be used for deep cloning. In summary, the benchmark provides an excellent comparison of three popular libraries for deep cloning and updating data structures in JavaScript. The choice ultimately depends on your specific needs, the size and complexity of your project, and your familiarity with each library's syntax and features.
Related benchmarks:
Lodash CloneDeep vs Immer Produce
lodash get vs native javascript
Immer(produce) vs lodash(cloneDeep)
Lodash CloneDeep vs Immer Produce with heavy load
Comments
Confirm delete:
Do you really want to delete benchmark?