Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
bigArray uniq vs set vs reduce few duplicate
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Array from Set
7K/s
Lodash Uniq
6K/s
Array reduce
4K/s
View exact numbers
Test name
Executions per second
✓
Array from Set
6,953 Ops/sec
Lodash Uniq
6,339 Ops/sec
Array reduce
4,487 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var testArr = Array.from({length: 10000}, () => Math.floor(Math.random() * 50))
Tests:
Array from Set
[...new Set(testArr)]
Lodash Uniq
_.uniq(testArr)
Array reduce
testArr.reduce((ids, cid) => {return ids.some((pid) => pid === cid) ? ids : ids.concat(cid);}, [])