Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash groupBy vs Object.groupBy 100k
(version: 0)
Comparing performance of: Lodash vs Native
Comparing performance of:
Lodash vs Native
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
Script Preparation code:
var max = 100000; var data = []; for (var i = 0; i <= max; i++) { data.push({ id: i }); }
Tests:
Lodash
_.groupBy(data, ({ id }) => id)
Native
Object.groupBy(data, ({ id }) => id)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
Native
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser/OS:
Chrome 139 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
426.7 Ops/sec
Native
185.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON and explain what's being tested, compared, and their pros and cons. **Benchmark Definition** The benchmark is comparing the performance of two approaches: 1. Lodash (`_.groupBy(data, ({ id }) => id)`): This is a popular JavaScript library that provides a wide range of functional programming helpers. 2. Native (using `Object.groupBy(data, ({ id }) => id)`): This approach uses the built-in `groupBy` method of the JavaScript `Object` prototype. **Pros and Cons** * **Lodash:** + Pros: - Provides a familiar and well-maintained API for common data manipulation tasks. - Allows for easy reuse in other projects. + Cons: - Introduces additional overhead due to the library's existence, parsing, and execution. - May not be optimized for performance. * **Native:** + Pros: - Eliminates the need for an external library, reducing overhead and potential dependencies. - Can be more efficient since it leverages the built-in `Object` prototype, which is likely already optimized by the JavaScript engine. + Cons: - Requires explicit knowledge of the `Object.groupBy` method to use correctly. **Other Considerations** * The benchmark uses a simple data structure (`data`) generated by pushing objects with an incrementing `id` property into an array. This ensures that both approaches are performing similar calculations on equivalent data. * The HTML preparation code includes the Lodash library, which is loaded from a CDN (Content Delivery Network). This might affect the benchmark's accuracy if the network latency or loading time of this library affects the test results. **Library and Syntax** The `_.groupBy` method from Lodash uses a syntax similar to functional programming languages. The callback function (`({ id }) => id`) takes an object as input, extracts the `id` property, and returns it. This allows for concise and expressive data grouping logic without modifying the original data structure. **Additional Notes** There are no special JavaScript features or syntax used in this benchmark. If there were any advanced features like async/await, Promises, or generators, they would likely be mentioned in the documentation. **Alternatives** Other alternatives to Lodash for data manipulation include: * Underscore.js: Similar to Lodash, but with a slightly different API and ecosystem. * Ramda: A more functional programming-focused library that provides a different set of helpers. * Built-in JavaScript methods: Depending on the specific use case, other built-in methods like `forEach`, `map`, or `reduce` might be suitable alternatives. Keep in mind that each alternative has its own trade-offs and performance characteristics. This benchmark helps compare the performance of Lodash with Native implementation, but depending on your specific needs, you may want to explore other options as well.
Related benchmarks:
lodash groupBy vs Array.reduce 100k with array push
lodash groupBy vs Array.reduce vs Object.groupBy 100k
Object.groupBy vs Array.reduce 100k
_.groupBy vs Object.groupBy 100k
Comments
Confirm delete:
Do you really want to delete benchmark?