Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash Uniq vs Javascript Set vs Ramda Strings
(version: 0)
Comparing performance of:
Lodash Uniq vs Javascript Set vs Ramda Uniq
Created:
2 years ago
by:
Guest
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 arrayToDedup = [] // 15 character long "random" string for (var i = 0; i <= 1000; i++) { arrayToDedup.push(Math.random().toString(36).substring(2, 7) + Math.random().toString(36).substring(2, 7) + Math.random().toString(36).substring(2, 7)); }
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 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0
Browser/OS:
Firefox 129 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash Uniq
16105.0 Ops/sec
Javascript Set
15527.5 Ops/sec
Ramda Uniq
5876.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **Benchmark Definition** The benchmark is designed to compare three approaches for removing duplicates from an array: 1. **Lodash Uniq**: A function provided by the Lodash library that removes duplicate elements from an array while preserving the original order. 2. **Javascript Set**: A native JavaScript built-in function that converts an array to a set (an unordered collection of unique elements) and then back to an array, effectively removing duplicates. 3. **Ramda Uniq**: A function provided by the Ramda library that removes duplicate elements from an array while preserving the original order. **Options Compared** The benchmark is comparing the performance of these three approaches: * Lodash Uniq: Using the `uniq` function from the Lodash library to remove duplicates. * Javascript Set: Using the built-in `Set` constructor and its methods to convert an array to a set and then back to an array. * Ramda Uniq: Using the `uniq` function from the Ramda library to remove duplicates. **Pros and Cons** Here's a brief summary of each approach: * **Lodash Uniq**: Pros: + Well-tested and widely used library + Supports various data structures (arrays, objects, etc.) + Can be used for more complex data processing tasks * Cons: + Additional dependency on the Lodash library + May not be suitable for very large datasets due to memory constraints * **Javascript Set**: Pros: + Native JavaScript implementation, so no external dependencies + Fast and efficient for small to medium-sized datasets + Supports various data structures (arrays, sets, etc.) * Cons: + Limited support for complex data processing tasks + May not be suitable for very large datasets due to performance limitations * **Ramda Uniq**: Pros: + Well-tested and widely used library in the functional programming community + Supports various data structures (arrays, objects, etc.) + Can be used for more complex data processing tasks * Cons: + Additional dependency on the Ramda library + May not be suitable for very large datasets due to memory constraints **Library and Syntax** The benchmark uses the following libraries: * Lodash: A utility library that provides various functions for working with arrays, objects, and more. * Ramda: A functional programming library that provides a series of immutable functions for working with arrays and objects. There are no special JavaScript features or syntax being tested in this benchmark. The test cases use standard JavaScript array methods (e.g., `push`, `set`) and built-in data structures (arrays, sets). **Alternatives** If you're looking for alternative approaches to remove duplicates from an array, here are a few options: * Using the `filter` method with a callback function to remove duplicates: `[...array].filter((value, index, self) => self.indexOf(value) === index)` * Using a custom implementation using a data structure like a hash table or a trie * Using a third-party library like Fastify or Knex.js that provides a `removeDuplicates` function Keep in mind that each approach has its own trade-offs and limitations, so it's essential to consider your specific use case and requirements when choosing an approach.
Related benchmarks:
Lodash uniqBy vs Set
Lodash uniqBy vs Set 10000
Lodash uniqBy vs Set vs Set spread
Ramda Uniq Vs Set 2
Comments
Confirm delete:
Do you really want to delete benchmark?