Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
set.get (not new set) vs native include vs lodash include in small data scale
(version: 0)
Comparing performance of:
lodash includes vs native includes vs set. has
Created:
one year 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 arr = [] for(var i = 0; i < 99; 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
4704726.0 Ops/sec
native includes
8601384.0 Ops/sec
set. has
9530770.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview** The provided JSON represents a benchmark test case for measuring the performance of three approaches: native `includes` method, `lodash.includes`, and `set.has`. The benchmark is designed to test the performance of these approaches on small datasets. **Approaches compared** 1. **Native `includes`**: This approach uses the built-in `includes` method in JavaScript, which checks if a value exists within an array. 2. **Lodash `includes`**: This approach uses the `_.includes()` function from the Lodash library, a popular utility library for JavaScript that provides various helper functions for tasks like array manipulation and iteration. 3. **Set `has`**: This approach uses the `has()` method of the Set data structure in JavaScript, which checks if a value exists within the set. **Pros and Cons** 1. **Native `includes`**: * Pros: Built-in function with low overhead, easy to understand and implement. * Cons: May be slower than Lodash or custom implementations due to its built-in nature. 2. **Lodash `includes`**: * Pros: Optimized for performance, widely used and tested, provides a simple and consistent API. * Cons: Requires an external dependency (the Lodash library), may add overhead due to the additional function call. 3. **Set `has`**: * Pros: Efficient implementation that uses a hash table data structure under the hood, can be faster than native includes for large datasets. * Cons: May have higher memory usage due to the set data structure, less intuitive API compared to native includes. **Library and Purpose** Lodash is a popular utility library for JavaScript that provides various helper functions for tasks like array manipulation, iteration, and more. In this benchmark, Lodash's `_.includes()` function is used as an alternative to the built-in `includes` method in JavaScript. **Special JS Features/Syntax** There are no special features or syntax mentioned in the provided JSON. The tests only use standard JavaScript functions and data structures. **Other Alternatives** If you want to explore other alternatives, here are a few options: 1. **Custom implementation**: You can implement your own `includes` function using a loop or recursive approach. 2. **Other libraries**: There are other libraries like FastIncludes, which provides a fast and optimized includes function. 3. **Built-in set operations**: If you're working with large datasets, you can use built-in set operations in JavaScript, such as `has()` for sets or `indexOf()` for arrays. These alternatives may offer different performance characteristics, ease of implementation, or trade-offs in terms of memory usage or overhead.
Related benchmarks:
set.get vs native include vs lodash include
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?