Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash uniq vs set 1234567890
(version: 0)
Comparing performance of:
Set vs Array
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js'></script>
Tests:
Set
var l = new Set(['SUI', 'USDC', 'XRP', 'USDT', 'ETH', 'USDC', 'ALPHA', 'USDT', 'SOL', 'USDC', 'NZD', 'USDG', 'WHALE', 'USDT', 'FDT', 'USDT', 'SOL', 'USDT', 'SOL', 'BTC', 'BTC', 'IDRT', 'FUSDC', 'USDC', 'USDT', 'BNB', 'BOT', 'USDT', 'HODL', 'USDT', 'BNB', 'USDT', 'USDT', 'USDC', 'HXD', 'USDC', 'XRP-USDT', 'XRP-USDT-SWAP', 'XLM', 'USDT', 'XRP', 'SGD', 'BTC', 'USDC', '1000PEPE', 'USDV', 'XRP', 'USD', 'BNB', 'USDG', 'TRX', 'USDT', 'MATIC', 'DAI', 'USDT', 'USD', 'THX', 'USDC', 'ETH', 'DAI', 'BTC', 'USD', 'MECHA', 'USDC', 'BNB', 'USD', 'TCG2', 'BNB', 'PKN', 'USDC', 'BNB', 'BUSD', 'ETH', 'USDT', 'BTEX', 'EUR', 'USN', 'USDT', 'BTC', 'EUR', 'BNB', 'USDC', 'XRP', 'EUR']); return l;
Array
var l = ['SUI', 'USDC', 'XRP', 'USDT', 'ETH', 'USDC', 'ALPHA', 'USDT', 'SOL', 'USDC', 'NZD', 'USDG', 'WHALE', 'USDT', 'FDT', 'USDT', 'SOL', 'USDT', 'SOL', 'BTC', 'BTC', 'IDRT', 'FUSDC', 'USDC', 'USDT', 'BNB', 'BOT', 'USDT', 'HODL', 'USDT', 'BNB', 'USDT', 'USDT', 'USDC', 'HXD', 'USDC', 'XRP-USDT', 'XRP-USDT-SWAP', 'XLM', 'USDT', 'XRP', 'SGD', 'BTC', 'USDC', '1000PEPE', 'USDV', 'XRP', 'USD', 'BNB', 'USDG', 'TRX', 'USDT', 'MATIC', 'DAI', 'USDT', 'USD', 'THX', 'USDC', 'ETH', 'DAI', 'BTC', 'USD', 'MECHA', 'USDC', 'BNB', 'USD', 'TCG2', 'BNB', 'PKN', 'USDC', 'BNB', 'BUSD', 'ETH', 'USDT', 'BTEX', 'EUR', 'USN', 'USDT', 'BTC', 'EUR', 'BNB', 'USDC', 'XRP', 'EUR']; return _.uniq(l);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Set
Array
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):
Let's break down what's being tested in the provided benchmark. **Benchmark Purpose:** The purpose of this benchmark is to compare the performance of two approaches for creating a unique array of strings: 1. Using a `Set` data structure (JavaScript's built-in Set object) 2. Using the `_.uniq()` function from the Lodash library **Options Compared:** * **Set**: Creating a Set from an array of strings and using its `size` property to get the number of unique elements. * **Array**: Using the Lodash library's `_.uniq()` function, which creates a new array with only unique elements. **Pros and Cons:** * **Set**: + Pros: Simple, efficient, and widely supported. + Cons: Requires JavaScript to be set up as a Set, which might incur additional overhead. * **Array**: Pros: Convenient, easy to understand, and doesn't require setting up a Set. Cons: Might have performance overhead due to the creation of an intermediate array. **Library Used:** Lodash Lodash is a popular utility library for JavaScript that provides a wide range of functions for tasks such as array manipulation, object transformation, and more. The `_.uniq()` function is one of its many useful utilities. **Special JS Feature/ Syntax:** None mentioned in this specific benchmark. **Other Alternatives:** If you wanted to create an array with unique elements without using Lodash's `_.uniq()`, you could use the `Array.prototype.reduce()` method and a Set to achieve the same result. Alternatively, you could use a library like MathJS or other specialized libraries for mathematical computations. In terms of benchmarking, it's worth noting that this test compares the performance of two approaches: 1. Using the built-in Set object (JavaScript). 2. Using Lodash's `_.uniq()` function (a third-party library). By comparing these two approaches, the benchmark aims to provide insight into the performance benefits of using a dedicated library versus relying on the language's built-in features. To get a better understanding of your specific use case, consider what trade-offs are important to you. If you need high performance and don't mind using an external library, Lodash might be a good choice. However, if you prefer to avoid additional dependencies or want to keep things simple, the Set approach might be more suitable.
Related benchmarks:
lodash uniq vs vanilla set - final
lodash uniq vs native uniq
Lodash uniq vs Set to unique array
lodash vs ES6 uniq
Lodash uniqBy vs Javascript uniqBy
Comments
Confirm delete:
Do you really want to delete benchmark?