Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash Uniq vs Javascript Set vs Ramda
(version: 0)
Comparing performance of:
Lodash Uniq vs Javascript Set vs Ramda Uniq
Created:
4 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.5/lodash.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.28.0/ramda.min.js"></script>
Script Preparation code:
var firstEqual = []; var secondEqual = []; for (var i=0; i<=1000000; i++) { firstEqual.push(i); secondEqual.push(i); } var arrayToDedup = [...firstEqual, ...secondEqual];
Tests:
Lodash Uniq
_.uniq(arrayToDedup);
Javascript Set
[...new Set(arrayToDedup)]
Ramda Uniq
R.uniq(arrayToDedup);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash Uniq
Javascript Set
Ramda Uniq
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser/OS:
Chrome 122 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash Uniq
5.2 Ops/sec
Javascript Set
4.6 Ops/sec
Ramda Uniq
3.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and its options. **Benchmark Definition** The benchmark is designed to compare the performance of three data deduplication methods: 1. Lodash `uniq` function 2. JavaScript built-in `Set` object 3. Ramda `R.uniq` function All three methods are tested on a large array of 1,000,000 unique elements. **Options Compared** The options being compared are the performance characteristics of each data deduplication method: * **Lodash Uniq**: The Lodash library provides a `uniq` function that removes duplicate elements from an array. This implementation has its own internal logic and may have additional overhead due to the library's functionality. * **JavaScript Set**: The JavaScript `Set` object is a built-in data structure designed for efficient set operations, including deduplication. It uses a hash table internally to store unique values. * **Ramda Uniq**: Ramda is a functional programming library that provides a `R.uniq` function similar to Lodash's `uniq`. This implementation may have different performance characteristics due to its design and internal logic. **Pros and Cons of Each Approach** Here are some general pros and cons for each approach: * **Lodash Uniq**: + Pros: Simple to use, well-documented, and widely adopted. + Cons: May have additional overhead due to library functionality, potentially slower performance compared to native JavaScript Set or Ramda Uniq. * **JavaScript Set**: + Pros: Fast, efficient, and optimized for set operations. It's also a built-in data structure, reducing dependencies. + Cons: Requires understanding of hash tables and may not be as straightforward to use for non-technical users. * **Ramda Uniq**: + Pros: Designed for functional programming, potentially more concise code, and optimized for performance. + Cons: May have a learning curve due to its functional programming paradigm, and some users might find it less intuitive than other approaches. **Library Descriptions** In this benchmark, the following libraries are used: * **Lodash**: A popular JavaScript utility library that provides a wide range of functions for tasks like data manipulation, string manipulation, and more. * **Ramda**: A functional programming library for JavaScript that provides a set of higher-order functions and data structures to simplify code and improve performance. **Other Considerations** When choosing an approach for data deduplication, consider the following factors: * Performance: If speed is crucial, native JavaScript Set or Ramda Uniq might be better choices. * Code readability: Lodash Uniq or Ramda Uniq might be more concise and readable depending on your programming style. * Dependencies: JavaScript Set requires no dependencies, while Lodash Uniq and Ramda Uniq introduce additional libraries. **Alternatives** If you're looking for alternative data deduplication methods or libraries, consider: * **Native JavaScript array methods**: The `filter` method can be used to remove duplicates from an array. * **Other functional programming libraries**: Libraries like Immutable.js or jQuery provide similar functionality to Ramda Uniq. * **Specialized libraries**: Libraries like FastSet or FastUnique offer optimized implementations for set operations.
Related benchmarks:
lodash includes vs ramda includes
lodash clone vs ramda clone vs spread
Ramda Uniq Vs Set 2
Ramda sort vs JS native sort vs Lodash
lodash uniq vs Array.from(new Set()) vs spread new Set() vs for vs for memory optimized 4
Comments
Confirm delete:
Do you really want to delete benchmark?