Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
uniqBy comparisons
(version: 0)
Comparing performance of:
Vanilla Set vs Ramda vs Lodash
Created:
2 years ago
by:
Guest
Jump to the latest result
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);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Vanilla Set
Ramda
Lodash
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
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/OS:
Chrome 126 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Vanilla Set
3506557.5 Ops/sec
Ramda
2404630.2 Ops/sec
Lodash
3804018.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll answer the questions based on the provided benchmarking results. **Question 1: Which JavaScript library is the fastest for implementing `uniqBy`?** Based on the latest benchmark result, Lodash is the fastest implementation with an average of 3804.018 executions per second. **Question 2: How do the performance differences between Vanilla Set and Ramda compare to Lodash?** Ramda is slightly faster than Vanilla Set (3506.557 executions per second) but slower than Lodash (3804.018 executions per second). The difference is relatively small, indicating that all three implementations are efficient. **Question 3: What is the optimal JavaScript library for implementing `uniqBy` in a benchmarking scenario?** Based on the latest benchmark result, Lodash appears to be the top performer among the three options. Its execution speed of approximately 3804 executions per second makes it an attractive choice for performance-critical applications. **Question 4: What are the implications of using Vanilla Set vs. Ramda/Lodash in a real-world scenario?** While the performance differences between these implementations may not be significant, choosing the right library can impact development time and maintainability. Lodash's syntax might be more familiar to developers who already use it, while Ramda's strict type annotations could provide additional safety guarantees. Vanilla Set, on the other hand, is a lightweight, built-in JavaScript solution that eliminates dependencies. If I had to pick one answer from each question: * Question 1: Lodash * Question 2: Lodash (slightly faster than Ramda, but slower than Vanilla Set) * Question 3: Lodash * Question 4: The choice ultimately depends on the specific requirements and preferences of the development team.
Related benchmarks:
Map, filter, concat, intersection comparison
lodash uniq vs Map
lodash uniq vs Map2
Map vs lodash.uniq
uniqBy performance and map
Comments
Confirm delete:
Do you really want to delete benchmark?