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:
8 months ago
by:
Registered User
Jump 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:
8 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
Test name
Executions per second
uniqBy
1827758.9 Ops/sec
Set
1621589.9 Ops/sec
Map
1551427.6 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?