Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
EGO Intersection lodash vs underscore vs manual
(version: 0)
Comparing performance of:
manual lodash vs manual underscore vs Lodash vs Underscore
Created:
4 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/underscore@1.13.1/underscore-min.js"></script>
Script Preparation code:
var underscore = _.noConflict(); var objectArrays = [ ['bedroom', 'kitchen', 'bathroom', 'living room', 'indoors', 'outdoors', 'city', 'urban', 'villa', 'hotel'], ['bed', 'kitchen island', 'bath', 'room', 'city'], ['bed', 'bathroom', 'bath', 'room', 'city'] ];
Tests:
manual lodash
let shared = []; objectArrays.forEach((array, i) => { if (i === 0) { shared.push(...array); } else { _.intersection(shared, array); } });
manual underscore
let shared = []; objectArrays.forEach((array, i) => { if (i === 0) { shared.push(...array); } else { underscore.intersection(shared, array); } });
Lodash
const arrayLodash = _.intersection(...objectArrays);
Underscore
const arrayUnderscore = underscore.intersection(...objectArrays);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
manual lodash
manual underscore
Lodash
Underscore
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 dive into the world of JavaScript microbenchmarks and explore what's being tested on this provided JSON. **Benchmark Overview** The benchmark compares the performance of three approaches to find the intersection of two arrays: 1. **Manual**: Implementing the `intersection` operation from scratch without using any libraries. 2. **Lodash**: Using the popular `lodash` library, which provides a robust set of utility functions for JavaScript development. 3. **Underscore**: Using the `underscore` library, which is similar to `lodash` but has some differences in its API. **Options Compared** The benchmark compares the performance of each approach on two identical sets of input arrays: * `objectArrays`: An array of two arrays, each containing a mix of strings and numbers. The comparison is done using the same test case with different implementations: one for manual implementation, one for Lodash, one for Underscore, and another for manual implementation again (with a slight variation). **Pros and Cons** * **Manual**: + Pros: Can be optimized for specific use cases, has no external dependencies. + Cons: Requires more code to implement, may have performance issues if not implemented correctly. * **Lodash**: + Pros: Robust library with extensive testing, easy to use and integrate. + Cons: Adds an external dependency, may have a higher overhead due to the extra abstraction layer. * **Underscore**: + Pros: Similar to Lodash but with some differences in its API, still a popular choice. + Cons: Also adds an external dependency, similar to Lodash. **Library Descriptions** * **Lodash**: A widely used JavaScript library that provides a comprehensive set of utility functions for tasks like array manipulation, object transformation, and more. It's known for its robust testing and extensive documentation. * **Underscore**: Another popular JavaScript library that provides a smaller set of functional programming helpers than Lodash. While similar to Lodash, Underscore has some differences in its API and is often preferred by developers who want a lighter weight alternative. **Special JS Features or Syntax** There are no special JavaScript features or syntax used in this benchmark. The code only uses standard JavaScript features like arrays, loops, and function calls. **Other Alternatives** If you're interested in exploring other approaches to find the intersection of two arrays, here are some alternatives: * Using `Set` objects: You can convert both arrays to sets and then use the `intersection` method to find the common elements. * Implementing a custom algorithm: There are several algorithms available that can be used to find the intersection of two arrays, such as the **Cartesian product** or the **Squeeze** algorithm. I hope this explanation helps you understand what's being tested in this benchmark!
Related benchmarks:
Lodash: difference vs intersection
Lodash: difference vs intersection vs includes
lodash merge vs deepmerge vs lodash/fp merge
Lodash Intersection vs. ES6 includes
Lodash Intersection vs. ES6 handle duplicate with set destructuration
Comments
Confirm delete:
Do you really want to delete benchmark?