Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash uniq vs set (String)
(version: 0)
Comparing performance of:
Set vs Lodash
Created:
3 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
return new Set(["1", "2", "3", "4", "5", "6", "7", "7", "7", "7", "1", "3", "0", "7", "4", "7"]);
Lodash
return _.uniq(["1", "2", "3", "4", "5", "6", "7", "7", "7", "7", "1", "3", "0", "7", "4", "7"]);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Set
Lodash
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Set
3627081.5 Ops/sec
Lodash
5355628.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'd be happy to help you understand the benchmark. **What is being tested?** The provided benchmark compares two approaches to remove duplicate elements from an array of strings: using a native JavaScript `Set` object and using the popular utility library Lodash's `uniq` function. The test measures the execution time for both methods on a specific input string containing duplicates. **Options compared:** * **Native JavaScript Set**: This approach uses the built-in `Set` object in JavaScript, which automatically removes duplicate elements. * **Lodash uniq**: This approach uses the Lodash library's `uniq` function to remove duplicate elements from an array. **Pros and Cons:** * **Native JavaScript Set:** + Pros: - Fast execution time - Built-in functionality eliminates the need for additional libraries - Simple to implement + Cons: - Not available in older browsers that don't support ES6+ - May not be suitable for large datasets due to memory constraints * **Lodash uniq:** + Pros: - Widely supported across different browsers and versions - Provides more features beyond just removing duplicates (e.g., sorting, filtering) - Well-documented and maintained library + Cons: - Adds extra overhead due to the use of a separate library - May be slower than native JavaScript Set for large datasets **Library: Lodash** Lodash is a popular utility library that provides a wide range of functions for tasks such as string manipulation, array manipulation, and more. The `uniq` function in Lodash removes duplicate elements from an array while preserving the original order. **Special JS feature or syntax: None** This benchmark does not utilize any special JavaScript features or syntax beyond the standard ES6+ syntax. **Other alternatives:** * **Array.prototype.filter()**: This approach can be used to remove duplicates by filtering out elements that already exist in a subset of the array. However, this method may not be as efficient as using a `Set` object for large datasets. * **D3 Set library**: Another alternative is to use the D3 Set library, which provides a similar functionality to Lodash's `uniq` function but with additional features and optimizations. Overall, the benchmark highlights the performance difference between using native JavaScript `Set` objects and external libraries like Lodash for tasks like removing duplicates from arrays.
Related benchmarks:
lodash uniq vs vanilla set - final
lodash uniq vs native uniq
uniqBy vs stringify performance
Lodash uniqBy vs Set 10000
lodash uniq vs spread new Set() medium size
Comments
Confirm delete:
Do you really want to delete benchmark?