Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash vs es6 map
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
lodash uniq
4577526.0 Ops/sec
es6 map
963117.2 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 data = [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 5}, {a: 6}, {a: 7}, {a: 8}, {a: 1}];
Tests:
lodash uniq
_.uniqBy(data, 'a');
es6 map
const uniqBy = (arr, predicate) => { const cb = typeof predicate === 'function' ? predicate : (o) => o[predicate]; return [...arr.reduce((map, item) => { const key = (item === null || item === undefined) ? item : cb(item); map.has(key) || map.set(key, item); return map; }, new Map()).values()]; }; uniqBy(data, 'a')