Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
_.uniqueBy vs Set vs Map
(version: 3)
Comparing performance of:
uniqBy vs Set vs Map
Created:
11 months ago
by:
Registered User
Go to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var MyArr = Array.from( { length: 40, }, () => { return { a: Math.floor(Math.random() * 40), }; } ); var myCopy = null;
Tests:
uniqBy
myCopy = _.uniqBy(MyArr, (obj) => obj.a);
Set
const seen = new Set(); myCopy = MyArr.filter(item => { if (seen.has(item.a)) { return false; } seen.add(item.a); return true; });
Map
const seen = new Map(); myCopy = MyArr.filter(item => { if (seen.has(item.a)) { return false; } seen.set(item.a, true); return true; });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
uniqBy
Set
Map
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser/OS:
Chrome 139 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
uniqBy
1.8M/s
Set
1.6M/s
Map
1.6M/s
View exact numbers
Test name
Executions per second
✓
uniqBy
1,827,759 Ops/sec
Set
1,621,590 Ops/sec
Map
1,551,428 Ops/sec
Related benchmarks
Lodash uniqBy vs Set
Lodash uniqBy vs Set 10000
Lodash uniqBy vs Set with Array of object
Lodash uniqBy vs Set vs Set spread
lodash uniq vs set my 2
New set vs UniqWith
ETST 123123123123123
Lodash uniqBy vs Set with Big array 24234234
Lodash uniqBy vs Set, big array
Comments
Confirm delete:
Do you really want to delete benchmark?