Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash Uniq vs Javascript Set vs Ramda with Ethereum Addresses
(version: 0)
An array of 1000 addresses where half of the addresses are duplicates
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 firstEqual = []; var secondEqual = []; function randomAddress() { const randomBytes = new Uint8Array(20); window.crypto.getRandomValues(randomBytes); const hexString = Array.from(randomBytes) .map(byte => byte.toString(16).padStart(2, '0')) .join(''); return '0x' + hexString; } for (var i=0; i<=500; i++) { const address = randomAddress(); firstEqual.push(address); secondEqual.push(address); } 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:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview** MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The benchmark provided in the JSON data measures the performance of three different approaches to remove duplicates from an array: Lodash's `uniq` function, JavaScript's built-in `Set` data structure, and Ramda's `uniq` function. **Tested Options** The three tested options are: 1. **Lodash Uniq**: This uses Lodash's `uniq` function to remove duplicate elements from the array. 2. **JavaScript Set**: This uses JavaScript's built-in `Set` data structure to remove duplicate elements from the array. The array is first converted to an array of unique values using the spread operator (`[...new Set(arrayToDedup)]`). 3. **Ramda Uniq**: This uses Ramda's `uniq` function to remove duplicate elements from the array. **Pros and Cons** * **Lodash Uniq**: Pros: Lodash is a popular and well-maintained library, its implementation is optimized for performance. Cons: Adds an additional dependency to the benchmark, may not be suitable for very large datasets due to memory constraints. * **JavaScript Set**: Pros: Built-in data structure, no dependencies, suitable for large datasets. Cons: May have performance issues with very large arrays due to the overhead of creating a new set, and may not be as efficient as optimized libraries like Lodash. * **Ramda Uniq**: Pros: Optimized implementation, suitable for large datasets. Cons: Adds an additional dependency to the benchmark, may not be as well-known or widely adopted as Lodash. **Library Descriptions** 1. **Lodash**: Lodash is a popular JavaScript utility library that provides a wide range of functions for tasks such as array manipulation, string manipulation, and functional programming. 2. **Ramda**: Ramda is a small, elegant, and efficient functional programming library for JavaScript that provides a variety of higher-order functions for data processing. **Special JS Feature/Syntax** This benchmark uses the following special JavaScript feature/syntax: * `let` and `var` are used to declare variables, but not `const`, which might be beneficial in this case since the array is modified. * The `window.crypto.getRandomValues()` function is used to generate random numbers for creating Ethereum addresses. **Alternatives** Other alternatives to these three approaches could include: * Using a custom implementation of a set data structure * Using a different library, such as underscore or moo-sets * Using a parallel processing approach with multiple threads or processes However, the above three options are commonly used and well-established solutions for removing duplicates from an array.
Related benchmarks:
Lodash Uniq vs Javascript Set Iterator vs Javascript Set Array.from
Ramda Uniq Vs Set 2
Lodash Uniq vs Javascript Set vs Ramda Strings
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?