Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test joinValueByColumns
(version: 0)
Comparing performance of:
lodash vs es6
Created:
6 years ago
by:
Registered User
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>
Tests:
lodash
let arrOfObj = {}; new Array(0x10000).fill('omg').map((v,k) => arrOfObj[`key${k}`] = v) // max 65536 const joined = _.filter(arrOfObj, (v, key) => _.includes(['key1', 'key599', 'key2679', 'key60000'], key)).join()
es6
let arrOfObj = {}; new Array(0x10000).fill('omg').map((v,k) => arrOfObj[`key${k}`] = v) // max 65536 const keys = Object.keys(arrOfObj).map((v, k) => ['key1', 'key599', 'key2679', 'key60000'].includes(v)?k:null).filter(x => x) const joined = Object.keys(arrOfObj).filter((v, k) => keys.includes(k)).join()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash
es6
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):
Let's break down the provided benchmark and explain what's being tested. **Benchmark Overview** The test case measures the performance of two approaches to join values by columns in an object array: using Lodash's `filter` function or writing a custom implementation using only ES6 syntax. **Options Compared** 1. **Lodash (lodash)**: * Purpose: A utility library that provides functional programming helpers, including filtering and mapping functions. * Pros: + Easy to use and familiar syntax for developers already comfortable with Lodash. + Well-tested and optimized for performance. * Cons: + Adds an external dependency to the benchmark, which may affect execution time. + May not be suitable for projects that need to minimize dependencies or have specific performance requirements. 2. **ES6 (custom implementation)**: * Purpose: A custom implementation using only ES6 syntax, without any additional libraries. * Pros: + No external dependency, making it suitable for projects with strict dependencies or performance optimization needs. + Allows developers to understand and optimize the inner workings of the code. * Cons: + Requires a deeper understanding of the underlying logic and potential performance trade-offs. + May not be as efficient or well-optimized as Lodash's implementation. **Library: Lodash** Lodash is a popular utility library that provides many functional programming helpers, including `filter` and `map`. In this benchmark, it's used to filter the object array based on the presence of specific keys. The `_.includes` function is used to check if an element exists in an array. **Special JS Feature/ Syntax: None** There are no special JavaScript features or syntaxes being tested in this benchmark. Both implementations rely on standard ES6 features and Lodash's API. **Other Alternatives** If you're interested in exploring alternative approaches, here are a few options: 1. **Array.prototype.filter()**: This is the built-in method for filtering arrays in JavaScript. While it may not be as optimized as Lodash's implementation, it can still provide good performance. 2. **Custom implementation using Array.prototype.indexOf() and Array.prototype.includes()**: You could implement a custom filter function using these two methods, but it might not be as efficient or readable as the ES6 implementation. 3. **Other libraries like underscore.js or Moment.js**: There are other libraries that offer similar functionality to Lodash, such as underscore.js or moment.js. However, they may have different APIs and performance characteristics. I hope this explanation helps you understand what's being tested in this benchmark!
Related benchmarks:
array join vs _.join
lodash vs es6 in join method
Join: Lodash vs Native
lodash join vs native join
Comments
Confirm delete:
Do you really want to delete benchmark?