Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
EGO Intersection lodash vs underscore
(version: 0)
Comparing performance of:
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 array1 = ['bedroom', 'kitchen', 'bathroom', 'living room', 'indoors', 'outdoors', 'city', 'urban', 'villa', 'hotel']; var array2 = ['bed', 'kitchen island', 'bath', 'room', 'city'];
Tests:
lodash
var arrayLodash = _.intersection(array1, array2);
underscore
var arrayUnderscore = underscore.intersection(array1, array2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
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 break down the provided benchmark and explain what's being tested. **Benchmark Overview** The benchmark compares the performance of two popular JavaScript libraries: Lodash and Underscore. Both libraries provide utility functions for tasks like array manipulation, string manipulation, and more. **Script Preparation Code** The script preparation code is a crucial part of the benchmark. It sets up the environment by: 1. Loading both Lodash and Underscore libraries. 2. Creating two sample arrays: `array1` and `array2`. 3. Storing references to these arrays in variables `arrayLodash` and `arrayUnderscore`. **Html Preparation Code** The HTML preparation code includes links to the CDN hosts of both Lodash and Underscore libraries. **Individual Test Cases** There are two individual test cases: 1. **Lodash**: The benchmark definition is a simple call to the `intersection()` function on `array1` using the `arrayLodash` variable. 2. **Underscore**: The benchmark definition is similar, but uses the `underscore.intersection()` function instead. **Options Compared** The main difference between Lodash and Underscore is how they implement their functions. Here are some pros and cons of each approach: * **Lodash:** + Pros: - More comprehensive set of utility functions (over 100). - Better support for functional programming. - Easier to use, with a more consistent API. + Cons: - Larger bundle size (~250KB). - Some users find the API too verbose or complex. * **Underscore:** + Pros: - Smaller bundle size (~80KB). - More lightweight and efficient, especially for small tasks. - Easier to learn and use for simple, low-level operations. + Cons: - Fewer utility functions compared to Lodash (around 50). - Less support for functional programming. **Library Overview** * **Lodash**: A popular JavaScript library that provides a comprehensive set of utility functions for tasks like array manipulation, string manipulation, and more. It's designed for use in web development and is widely used in the industry. * **Underscore**: Another popular JavaScript library that provides a smaller set of utility functions compared to Lodash. It was created by Jeremy Ashkenas, one of the creators of Prototype.js. **Special JS Features/Syntax** There are no specific special features or syntaxes being tested in this benchmark. The focus is on comparing the performance of two different libraries. **Alternatives** If you're considering using an alternative library for array manipulation and string manipulation tasks, some popular options include: * **Moment.js**: A lightweight JavaScript library for working with dates and times. * **JSZip**: A JavaScript library for working with ZIP archives. * **Fastest**: A JavaScript library that aims to provide the fastest possible performance for common operations like array manipulation and string concatenation. In terms of pure utility functions, you might also consider using a library like: * **Immutable.js**: A library that provides immutable data structures and functional programming utilities. * **Ramda**: A functional programming library that provides a small set of high-level functions for tasks like array filtering and mapping.
Related benchmarks:
Replace _.intersection
Lodash Intersection vs. ES6 includes
Lodash Intersection vs. ES6 handle duplicate
Lodash Intersection vs. ES6 handle duplicate with set destructuration
Lodash, Set, Array comparison
Comments
Confirm delete:
Do you really want to delete benchmark?