Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
set.get vs native include vs lodash include
(version: 1)
Comparing performance of:
lodash includes vs native includes vs set. has
Created:
one year 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>
Script Preparation code:
var arr = [] for(var i = 0; i < 999999; i++) { arr.push(Math.random()) } var demoSet = new Set(arr)
Tests:
lodash includes
_.includes(arr, Math.random())
native includes
arr.includes(Math.random())
set. has
demoSet.has(Math.random())
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
lodash includes
native includes
set. has
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser/OS:
Chrome 126 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash includes
2200.1 Ops/sec
native includes
6791.1 Ops/sec
set. has
4972300.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark definition and test cases. **Benchmark Definition Json** The provided JSON represents a benchmarking scenario where three different approaches are compared: 1. `set.get vs native include`: This option tests the performance of using the `has()` method on a `Set` object (native implementation) versus including an element in the set using the `includes()` method or a custom implementation provided by Lodash. 2. `lodash include vs native includes`: This option tests the performance of using the `_.includes()` function from Lodash versus the `includes()` method. **Options Compared** The benchmark compares three options: * Native approach: Using the `has()` method on a `Set` object (native implementation) + Pros: - Efficient and native to JavaScript - Does not require any additional libraries + Cons: - May have limitations in terms of performance or behavior on specific browsers/versions * Lodash approach: Using the `_.includes()` function from Lodash + Pros: - Often provides a simple and convenient implementation for common use cases - Can be more predictable and consistent across different browsers and versions + Cons: - Requires an additional library to be included in the benchmark - May introduce overhead due to the inclusion of the Lodash library * Custom approach: Including an element in the set using a custom implementation (not shown in the provided JSON) + Pros: - Could potentially be optimized for performance or behavior specific to a particular use case + Cons: - Requires additional development effort and maintenance **Library and Purpose** Lodash is a popular JavaScript library that provides a collection of utility functions, including `_.includes()`. The purpose of using Lodash in this benchmark is to provide an alternative implementation for the `includes()` method, allowing developers to compare its performance with the native approach. **Special JS Feature or Syntax** The test cases do not appear to use any special JavaScript features or syntax. They only utilize standard JavaScript data structures (arrays and sets) and methods (`push()`, `has()`, and `includes()`). **Other Alternatives** If you were to create a custom implementation for including an element in the set, you might consider using a more efficient algorithm, such as a hash table or a Bloom filter. However, this would require significant additional development effort and maintenance. In terms of alternative libraries or frameworks, other popular JavaScript libraries that provide similar functionality to Lodash include: * Underscore.js: Another popular utility library for JavaScript. * Moment.js: A library for working with dates and times (not relevant to the benchmark). Keep in mind that these alternatives would require additional development effort and may introduce overhead due to the inclusion of new libraries.
Related benchmarks:
Unique lodash vs vanilla
set.get(with new set) vs native include vs lodash include
set.get(with new set) vs native include vs lodash include in small data scale
set.get vs native include vs lodash include in small data scale
Comments
Confirm delete:
Do you really want to delete benchmark?