Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash UniqueWith vs custom filter with isEqual for duplicates
(version: 0)
Comparing performance of:
_.uniqWith vs filter
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var myArray = Array(7000).fill({a:1, b:2});
Tests:
_.uniqWith
myArray = _.uniqWith(myArray, _.isEqual);
filter
const trackObj = {}; myArray = myArray.filter(item => { if (trackObj[item.a]) { const foundDuplicateValue = (trackObj[item.a]).some((val) => { return _.isEqual(val, item.b); }); // If no duplicate value found, do nothing in this if block. // If duplicate value found, return false. This will filter out this datum. if (foundDuplicateValue) return false; } if (!trackObj[item.a]) { trackObj[item.a] = [item.b]; } else { trackObj[item.a].push(item.b); } return true; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
_.uniqWith
filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0
Browser/OS:
Firefox 140 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
_.uniqWith
18980256.0 Ops/sec
filter
10982267.0 Ops/sec
Related benchmarks:
unique elements in array using filter
uniqBy vs stringify performance
get uniq values js
Lodash uniqBy vs Javascript uniqBy
lodash uniq vs spread new Set() medium size
Comments
Confirm delete:
Do you really want to delete benchmark?