Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
uniqBy vs filter+set
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
lodash/uniqBy
193008.7 Ops/sec
filter+set
341110.6 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 smalldata = [1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok']; var bigdata = [1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok',1,2,3,4,5,'ok','abc','def',null,undefined,1,2,3,'ok']; var uniqBy = (arr, fn) => { var dups = new Set(); return arr.filter((v) => { const k = fn(v); if (dups.has(k)) { return false; } dups.add(k); return true; }); };
Tests:
lodash/uniqBy
_.uniqBy(smalldata, (v) => v); _.uniqBy(bigdata, (v) => v);
filter+set
uniqBy(smalldata, (v) => v); uniqBy(bigdata, (v) => v);