Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
uniq across _, R, Set
(version: 0)
Comparing performance of:
Lodash vs Ramda vs Set
Created:
5 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.27.0/ramda.js"></script>
Script Preparation code:
var data = [..._.range(1000).map(function(i) { return { counter: i } }),..._.range(1000).map(function(i) { return { counter: i } })];
Tests:
Lodash
var result = _.uniq(data);
Ramda
var result = R.uniq(data);
Set
var result = Array.from(new Set(data));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash
Ramda
Set
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser/OS:
Chrome 144 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
16489.2 Ops/sec
Ramda
3.1 Ops/sec
Set
20937.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the explanation of what is being tested in this JavaScript microbenchmark. **Overview** The benchmark compares the performance of three approaches to remove duplicates from an array: 1. Lodash (`_.uniq` function) 2. Ramda (`R.uniq` function) 3. Built-in `Set` object (`Array.from(new Set(data))`) **Approaches Compared** Each approach has its own pros and cons: ### 1. Lodash (`_.uniq` function) * Pros: + Well-maintained and widely used library + Provides a convenient way to remove duplicates from arrays + Can handle complex data structures, such as objects and arrays with nested properties * Cons: + Adds an extra dependency (Lodash) to the test + May have additional overhead due to the size of the Lodash library ### 2. Ramda (`R.uniq` function) * Pros: + Small footprint compared to Lodash + Provides a functional programming style that can be beneficial for performance + Can handle complex data structures, such as objects and arrays with nested properties * Cons: + Less widely used than Lodash, which may affect compatibility + May require additional setup or configuration ### 3. Built-in `Set` object (`Array.from(new Set(data))`) * Pros: + Fast and lightweight, as it uses the built-in `Set` data structure + Does not add any external dependencies + Provides a simple and efficient way to remove duplicates * Cons: + May not work correctly for complex data structures or arrays with nested properties + Can be slower than Lodash or Ramda for very large datasets **Library Descriptions** Both Lodash and Ramda are popular JavaScript libraries that provide functional programming utilities. They are often used in conjunction with each other to build more complex applications. * Lodash (`lodash.js`) is a general-purpose utility library that provides a wide range of functions for tasks such as string manipulation, array manipulation, and object transformation. * Ramda (`ramda.js`) is a functional programming library that provides a set of pure functions for tasks such as data transformation, filtering, and mapping. **Special JS Feature or Syntax** None mentioned in the provided code. However, it's worth noting that some newer JavaScript features and syntax may be used in more recent versions of Lodash and Ramda. **Other Alternatives** If you're looking for alternative approaches to remove duplicates from an array, you might consider: * Using a simple `for` loop with an object to keep track of unique values * Utilizing a library like `punch` or `fast-deep-equal` that provides optimized duplicate removal functions * Implementing your own custom solution using JavaScript's built-in data structures and algorithms Keep in mind that the choice of approach will depend on the specific requirements and constraints of your project.
Related benchmarks:
Lodash vs Ramda
lodash includes vs ramda includes
R vs _ uniq
uniqBy : Lodash vs Ramda
own uniq or ramda
Comments
Confirm delete:
Do you really want to delete benchmark?