Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
uniqBy comparisons
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Vanilla Set
1349812.2 Ops/sec
Ramda
937295.2 Ops/sec
Lodash
1465046.4 Ops/sec
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.29.1/ramda.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
Script Preparation code:
var dag = { nodes: [{ id: '1' }, { id: '2' }, { id: '3' }, { id: '4' }], links: [{ fromId: '1', fromPort: 'Output', toId: '2', toPort: 'Input' }, { fromId: '1', fromPort: 'Output', toId: '3', toPort: 'Input' }, { fromId: '2', fromPort: 'Output', toId: '4', toPort: 'Input' }, { fromId: '3', fromPort: 'Output', toId: '4', toPort: 'Input' },{ fromId: '1', fromPort: 'Output', toId: '2', toPort: 'Input' }, { fromId: '1', fromPort: 'Output', toId: '3', toPort: 'Input' }, { fromId: '2', fromPort: 'Output', toId: '4', toPort: 'Input' }, { fromId: '3', fromPort: 'Output', toId: '4', toPort: 'Input' },{ fromId: '1', fromPort: 'Output', toId: '2', toPort: 'Input' }, { fromId: '1', fromPort: 'Output', toId: '3', toPort: 'Input' }, { fromId: '2', fromPort: 'Output', toId: '4', toPort: 'Input' }, { fromId: '3', fromPort: 'Output', toId: '4', toPort: 'Input' },{ fromId: '1', fromPort: 'Output', toId: '2', toPort: 'Input' }, { fromId: '1', fromPort: 'Output', toId: '3', toPort: 'Input' }, { fromId: '2', fromPort: 'Output', toId: '4', toPort: 'Input' }, { fromId: '3', fromPort: 'Output', toId: '4', toPort: 'Input' },{ fromId: '1', fromPort: 'Output', toId: '2', toPort: 'Input' }, { fromId: '1', fromPort: 'Output', toId: '3', toPort: 'Input' }, { fromId: '2', fromPort: 'Output', toId: '4', toPort: 'Input' }, { fromId: '3', fromPort: 'Output', toId: '4', toPort: 'Input' },{ fromId: '1', fromPort: 'Output', toId: '2', toPort: 'Input' }, { fromId: '1', fromPort: 'Output', toId: '3', toPort: 'Input' }, { fromId: '2', fromPort: 'Output', toId: '4', toPort: 'Input' }, { fromId: '3', fromPort: 'Output', toId: '4', toPort: 'Input' },{ fromId: '1', fromPort: 'Output', toId: '2', toPort: 'Input' }, { fromId: '1', fromPort: 'Output', toId: '3', toPort: 'Input' }, { fromId: '2', fromPort: 'Output', toId: '4', toPort: 'Input' }, { fromId: '3', fromPort: 'Output', toId: '4', toPort: 'Input' } ] }
Tests:
Vanilla Set
function uniqBy(fn, list) { var set = new Set(); var result = []; var idx = 0; var appliedItem, item; while (idx < list.length) { item = list[idx]; appliedItem = fn(item); if (set.add(appliedItem)) { result.push(item); } idx += 1; } return result; } const uniqByFromId = uniqBy(l => l.fromId, dag.links);
Ramda
const uniqByFromId = R.uniqBy(l => l.fromId, dag.links);
Lodash
const uniqByFromId = _.uniqBy(dag.links, l => l.fromId);