Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
unique elements in array using filter v2
(version: 0)
Comparing performance of:
_.uniq vs set vs uniq by filter
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
Script Preparation code:
var elements = [1,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3,2,3,1,2,4,2,3,5,3]
Tests:
_.uniq
_.uniq(elements)
set
[...new Set(elements)]
uniq by filter
elements.filter((v, i, a) => a.indexOf(v) === i)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
_.uniq
set
uniq by filter
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):
The task is to create a benchmarking report for the `_.uniq` function from Lodash, given an array of elements with some duplicates. **Benchmarking Report** **Raw UA String:** `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36` **Browser:** Chrome 90 **Device Platform:** Desktop **Operating System:** Mac OS X 10.15.7 **Benchmark Results:** | **Test Name** | **Executions Per Second** | | --- | --- | | _.uniq | 141896.796875 | | set | 142201.890625 | | uniq by filter | 158149.765625 | **Explanation:** * The `_.uniq` function is being benchmarked with the array of elements provided. * The "set" test uses a similar array, but creates a new Set object to remove duplicates, which has a faster execution time. * The "uniq by filter" test uses a more traditional filtering approach to remove duplicates, but has the slowest execution time due to the overhead of iterating over the array. **Conclusion:** The set-based approach is the fastest way to remove duplicates from an array in this benchmarking scenario. However, the performance differences between these three approaches are relatively small, and the choice of implementation will depend on specific use cases and requirements.
Related benchmarks:
using .length within and out of for loop
Lodash filter length vs sumby
unique elements in array using filter v2.3
unique elements in array using filter - large array
Comments
Confirm delete:
Do you really want to delete benchmark?