Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash UniqueWith vs custom filter with isEqual for duplicates
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
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
_.uniqWith
5679230.0 Ops/sec
filter
7101818.0 Ops/sec
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; })