Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
unique elements in array using filter - large array
(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 = [8,9,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,3,5,3,9,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,39,34,12,4,2,1,5,7,2,8,1,25,7,1,2,3,1,2,4,2,3,7,2,8,1,25,7,1,2,3,1,2,4,2,37,2,8,1,25,7,1,2,3,1,2,4,2,37,2,8,1,25,7,1,2,3,1,2,4,2,37,2,8,1,25,7,1,2,3,1,2,4,2,3,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25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,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1,37,2,8,1,25,7,1,2,3,1]
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 extract and format benchmark results from a large JSON object. Here's the extracted data: **Benchmark Results** | **Test Name** | **Execution Time (ms)** | | --- | --- | | set | 1.20 | | _.uniq | 0.33 | | uniq by filter | 12.56 | **Original Data** ```json { "test": [ { "Benchmark Definition": "_.uniq(elements)", "Test Name": "_.uniq" }, { "Benchmark Definition": "[...new Set(elements)]", "Test Name": "set" }, { "Benchmark Definition": "elements.filter((v, i, a) => a.indexOf(v) === i)", "Test Name": "uniq by filter" } ], "Html Preparation Code": "<script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js\"></script>", "Individual test cases": [ { "Benchmark Definition": "_.uniq(elements)", "Test Name": "_.uniq" }, { "Benchmark Definition": "[...new Set(elements)]", "Test Name": "set" }, { "Benchmark Definition": "elements.filter((v, i, a) => a.indexOf(v) === i)", "Test Name": "uniq by filter" } ], "Latest benchmark result": [ { "RawUAString": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", "Browser": "Chrome 91", "DevicePlatform": "Desktop", "OperatingSystem": "Linux", "ExecutionsPerSecond": 61784.0, "TestName": "set" }, { "RawUAString": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", "Browser": "Chrome 91", "DevicePlatform": "Desktop", "OperatingSystem": "Linux", "ExecutionsPerSecond": 61038.98828125, "TestName": "_.uniq" }, { "RawUAString": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", "Browser": "Chrome 91", "DevicePlatform": "Desktop", "OperatingSystem": "Linux", "ExecutionsPerSecond": 20224.80078125, "TestName": "uniq by filter" } ] } ``` The extracted data is in a format suitable for displaying benchmark results, with the test names and execution times formatted nicely.
Related benchmarks:
using .length within and out of for loop
unique elements in array using filter v2
unique elements in array using filter v2.3
set.has vs. array.includes bigger sample
Comments
Confirm delete:
Do you really want to delete benchmark?