Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Native vs Lodash.js contains / fork
(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; 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:
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 JSON and explain what's being tested, compared, and the pros/cons of different approaches. **Benchmark Definition** The benchmark is comparing three JavaScript methods: native `includes` and `indexOf`, as well as Lodash.js implementation of `_includes`. **Native vs. Lodash.js contains/fork** This test case compares the performance of two approaches: 1. **Native**: Using built-in JavaScript functions for `includes` and `indexOf`. 2. **Lodash.js**: Using the popular utility library Lodash.js, which provides a more concise way to achieve similar functionality. **Pros and Cons:** * **Native**: + Pros: Built-in functions are likely to be optimized by JavaScript engines. + Cons: May have slower performance due to interpreter overhead or cache misses. * **Lodash.js**: + Pros: More concise code, potential for better caching or optimization opportunities. + Cons: Introduces an additional dependency (the Lodash library), which may not be desirable in all cases. **Library: Lodash.js** Lodash.js is a popular JavaScript utility library that provides a wide range of functions for tasks like array manipulation, string manipulation, and more. The `_includes` function is part of the Lodash.js suite, providing a more concise way to check if an element is included in an array. **Special JS Feature/ Syntax** None are explicitly mentioned in the provided code. **Other Alternatives:** If you're interested in exploring alternative methods for `includes` and `indexOf`, here are some options: * **ES6's Optional Chaining**: You can use optional chaining (`?.`) to achieve similar results, e.g., `arr2['includes'](-100000)`. However, this approach may not be as performant or widely supported. * **Other libraries or frameworks**: Depending on the specific requirements, other libraries like Ramda.js or Array.prototype's built-in methods (e.g., `findIndex()`) might offer alternative solutions. Keep in mind that these alternatives are not explicitly mentioned in the provided code and may have different performance characteristics.
Related benchmarks:
Native vs Lodash.js contains
Lodash.js vs Native isArrary
Lodash.js vs Native _.min
Lodash.js vs Native forked
Comments
Confirm delete:
Do you really want to delete benchmark?