Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash includes vs ramda includes
(version: 0)
Comparing performance of:
Ramda uniq vs Lodash uniq
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.26.1/ramda.min.js"></script>
Script Preparation code:
var arr = [1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]
Tests:
Ramda uniq
R.uniq(arr);
Lodash uniq
_.uniq(arr);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Ramda uniq
Lodash uniq
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0
Browser/OS:
Chrome 143 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Ramda uniq
5760158.5 Ops/sec
Lodash uniq
23570936.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the benchmark for you. **Benchmark Overview** The benchmark compares two functions: `_.uniq(arr)` from Lodash and `R.uniq(arr)` from Ramda. The script preparation code initializes an array `arr` with 14 elements, all of which are equal to 7. This is done to test both functions' performance when removing duplicates. **Options Compared** The two options being compared are: 1. **Lodash's _.uniq() function**: This function takes an array as input and returns a new array containing only unique elements. 2. **Ramda's R.uniq() function**: Similar to Lodash's implementation, this function also removes duplicate elements from an array. **Pros and Cons of Each Approach** Both functions have similar functionality, but there are some differences in their implementation: * **Performance**: Ramda's `R.uniq()` might be slightly faster due to its functional programming style and use of memoization. Lodash's implementation is more imperative and uses a simple algorithm to remove duplicates. * **Readability**: Both functions have clear names and signatures, making them easy to understand for developers familiar with the libraries. However, Ramda's `R.uniq()` might be considered more concise due to its use of higher-order functions. **Library Descriptions** 1. **Lodash**: Lodash is a popular JavaScript utility library that provides a wide range of functions for common tasks such as array manipulation, string formatting, and object creation. _.uniq() is one of the many utility functions available in the library. 2. **Ramda**: Ramda is another popular JavaScript functional programming library that offers a set of curried functions for data processing, transformation, and manipulation. R.uniq() is part of Ramda's core functionality. **Special JS Feature or Syntax** There isn't any special JavaScript feature or syntax used in this benchmark. Both Lodash and Ramda use standard JavaScript features like function declarations and arrow functions. **Other Alternatives** If you're interested in alternative approaches for removing duplicates, here are some other options: * **JavaScript's built-in `Set` data structure**: You can use the `Set` object to remove duplicates from an array by converting it to a set and then back to an array. * **Google's Closure Library's `Array.unique()` function**: This function provides a similar functionality to Lodash's _.uniq() but is part of Google's Closure Library. Keep in mind that these alternatives might have different performance characteristics, readability, or maintainability compared to the benchmarked functions.
Related benchmarks:
Ramda pipe vs lodash flow
lodash merge vs deepmerge vs ramda
Lodash vs Ramda vs Native fromPairs
Last element (Native vs Ramda vs Lodash)
Comments
Confirm delete:
Do you really want to delete benchmark?