Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash groupBy vs Array.reduce vs Ramda on million items
(version: 0)
Comparing performance of:
Lodash vs Native vs Ramda
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
Script Preparation code:
var max2 = 1000000; var data = []; for (var i = 0; i <= max2; i++) { data.push({ id: i }); }
Tests:
Lodash
_.groupBy(data, ({ id }) => id)
Native
data.reduce((acc, item) => { acc[item.id] = item; return acc; }, {})
Ramda
R.groupBy(data => data.id)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash
Native
Ramda
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
30.1 Ops/sec
Native
79.2 Ops/sec
Ramda
165029312.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Measuring the performance of different approaches to group data by an identifier using JavaScript libraries like Lodash, Ramda, and native code. **Overview** The benchmark compares three approaches: 1. **Lodash**: Using the `_.groupBy()` function from Lodash library. 2. **Native**: Implementing the grouping logic using a simple loop in JavaScript. 3. **Ramda**: Using the `R.groupBy()` function from Ramda library. **Options Compared** * Memory usage: None explicitly mentioned, but Ramda's `R.groupBy()` might be more memory-efficient due to its immutability and ability to handle large datasets without modifying the original data. * Computational complexity: The native approach has a time complexity of O(n), while Lodash and Ramda have a time complexity of O(n log n) due to their recursive or iterative implementations. **Pros and Cons** * **Native**: Pros: + Faster execution times, especially for large datasets. + No additional dependencies or libraries required. + Control over the implementation and performance optimization. * Cons: + Requires manual memory management, which can be error-prone. + Limited to JavaScript engines that support its optimizations. * **Lodash**: Pros: + Easy to use and understand for developers familiar with Lodash. + Provides a familiar API for grouping data. + Can be faster than native code due to caching and optimization techniques. * Cons: + Adds an additional dependency to the project. + May not be as performant as native code or Ramda's implementation. * **Ramda**: Pros: + Immutability ensures thread-safety and predictability. + Provides a concise and expressive API for grouping data. + Can be faster than Lodash due to its optimized implementation. * Cons: + Requires an additional dependency to the project. + May have a steeper learning curve due to its functional programming paradigm. **Library Descriptions** * **Lodash**: A popular JavaScript utility library that provides a wide range of functions for tasks like data manipulation, string manipulation, and more. `_.groupBy()` is a part of Lodash's data manipulation module. * **Ramda**: A functional programming library for JavaScript that provides a set of pure functions for common tasks like array operations, object manipulation, and more. `R.groupBy()` is a part of Ramda's collection of grouping and filtering functions. **Special JS Features or Syntax** None mentioned explicitly in the provided benchmark definition.
Related benchmarks:
lodash groupBy vs Array.reduce (1mln)
lodash groupBy vs Array.reduce (2)
lodas2 groupBy vs Array.reduce
lodash groupBy vs Array.reduce on million items
lodash groupBy vs Array.reduce 100k with array push
Comments
Confirm delete:
Do you really want to delete benchmark?