Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Native vs Lodash.js contains
(version: 0)
Comparing performance of:
Native_include vs Native_index of vs lodash
Created:
7 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
var max1 = 100000; // 100,000 (100 Thousand) var max2 = 10000000; // 10,000,000 (10 Million) var max3 = 100000000; // 100,000,000 (100 Million) var arr1 = []; //for (var i = 0; i <= max1; i++) { arr1.push(i); } var arr2 = []; for (var i = 0; i <= max2; i++) { arr2.push(i); } var arr3 = []; //for (var i = 0; i <= max3; i++) { arr3.push(i); }
Tests:
Native_include
arr2.includes(-100000);
Native_index of
arr2.indexOf(-100000);
lodash
_.includes(arr2, -100000);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Native_include
Native_index of
lodash
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native_include
304.1 Ops/sec
Native_index of
315.6 Ops/sec
lodash
89.1 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The provided benchmark definition json represents a test case where the performance of three different methods (native, Lodash.js, and _.includes) are compared for finding an element in an array with a specific value. **Tested Options** The tested options are: 1. **Native**: This option uses the built-in JavaScript array methods `includes()` and `indexOf()`. 2. **Lodash.js**: This option uses the Lodash library's `_includes()` function. 3. **_.includes**: This option is a direct reference to the Lodash library's `_includes()` function. **Pros and Cons of Each Approach** 1. **Native**: * Pros: Built-in methods are usually optimized for performance and can be faster than external libraries. * Cons: May not work as expected in all browsers or versions, especially if there are polyfills required. 2. **Lodash.js**: * Pros: A well-maintained and widely used library that provides a robust implementation of the `_includes()` function. * Cons: Adds an extra layer of complexity and may incur performance overhead due to the need for a separate library. 3. **_.includes**: * Pros: Direct access to the Lodash library's optimized implementation, potentially faster than using the `_.includes()` function directly. * Cons: May not be as intuitive or familiar to developers who are not already using Lodash. **Library and Syntax Considerations** In this benchmark, the Lodash library is used for its `_includes()` function. The _.includes() function takes two arguments: the array and the value to search for. In this case, the second argument is a single value (-100000). The use of Lodash in this benchmark provides a controlled environment for comparing the performance of different methods. **Special JS Feature or Syntax** None are mentioned in this specific benchmark definition. **Alternative Approaches** Other approaches that could be used to find an element in an array with a specific value include: * Using `Array.prototype.includes()` and then filtering the result using `Array.prototype.filter()` * Implementing a custom binary search algorithm * Using a third-party library like Fast.js or js-arrays These alternative approaches may offer different performance profiles compared to the native, Lodash.js, and _.includes methods tested in this benchmark.
Related benchmarks:
Lodash.js vs Native isArrary
Lodash.js vs Native _.min
Lodash.js(last) vs Native(at)
Lodash.js vs Native1
Comments
Confirm delete:
Do you really want to delete benchmark?