Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
taetas
(version: 0)
Comparing performance of:
ES6 vs lodash
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var userInfo = [ { id: 1, name: 'kim', age: 22, }, { id: 2, name: 'park', age: 25, }, { id: 3, name: 'lee', age: 25, }, { id: 4, name: 'choi', age: 21, }, ];
Tests:
ES6
const groupedUsingReduce = userInfo.reduce((acc, cur) => { acc[cur.age] = acc[cur.age] || []; acc[cur.age].push(cur) return acc }, {}) const filtered = Object.fromEntries( Object.entries(groupedUsingReduce).filter(([key, value]) => (parseInt(key) < 25) ) )
lodash
const filtered = _.chain(userInfo) .groupBy('age') .pickBy((value, key) => parseInt(key) < 25) .value();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
ES6
lodash
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview of the Benchmark** The provided JSON represents a JavaScript microbenchmark on MeasureThat.net, which compares the performance of two different approaches to group and filter an array of objects. **What is tested?** Two individual test cases are compared: 1. **ES6**: Uses the native `reduce` method to group objects by age and then filters out those with ages greater than or equal to 25. 2. **Lodash**: Uses the Lodash library's `groupBy` and `pickBy` functions to achieve the same result as ES6. **Options compared** The two options are compared in terms of their performance, which is measured by the number of executions per second (ExecutionsPerSecond). **Pros and Cons of each approach** * **ES6**: The native `reduce` method provides a compact and efficient solution. However, it may not be immediately recognizable to developers without experience with JavaScript's array methods. * **Lodash**: Lodash is a widely-used library that provides a robust set of utility functions for common tasks like grouping and filtering arrays. While it may add overhead due to the inclusion of the library itself, its readability and maintainability might be considered advantages by some. **Library usage** The `lodash` library is used in the second test case. Lodash is a popular JavaScript library that provides a wide range of functions for tasks like array manipulation, string manipulation, and more. In this benchmark, Lodash's `groupBy` and `pickBy` functions are used to group objects by age and filter out those with ages greater than or equal to 25. **Special JS feature/syntax** There is no special JavaScript feature or syntax used in either test case. **Other alternatives** If you're interested in exploring alternative approaches, here are a few options: * **Array.prototype.reduce()**: This is the native method used by ES6, which provides a more concise solution. * **D3.js**: While not directly related to grouping and filtering arrays, D3.js (Data-Driven Documents) is a popular library for data visualization that provides various array manipulation functions. * **Underscore.js**: Another popular JavaScript library that provides an alternative implementation of `groupBy` and `pickBy` functions. Keep in mind that the performance differences between these alternatives might be negligible or not noticeable, depending on the specific use case and dataset.
Related benchmarks:
lodash vs es6 in find method
Map lodash and PureJS
aadasdsa
find scope compare
A native map vs lodash _.map
Comments
Confirm delete:
Do you really want to delete benchmark?