Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
string IndexOf vs string Includes vs lodash includes vs lodash indexOf
(version: 0)
urls
Comparing performance of:
string IndexOf vs string Includes vs lodash includes vs lodash indexOf
Created:
6 years 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 _str = 'https://test.org.com/test/test/test/azaza?param1=123123¶m2=890859083459083405jlk&{utms}&test_param=[asd]qwd';
Tests:
string IndexOf
_str.indexOf('{utms}') !== -1
string Includes
_str.includes('{utms}')
lodash includes
_.includes(_str, '{utms}')
lodash indexOf
_.indexOf(_str, '{utms}') !== -1
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
string IndexOf
string Includes
lodash includes
lodash indexOf
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):
The provided JSON represents a JavaScript benchmark test case on MeasureThat.net. The test measures the performance of three different string methods in JavaScript: `indexOf`, `includes`, and their respective counterparts from the Lodash library, `_.indexOf` and `_.includes`. **Options being compared:** 1. **Native `string.indexOf`**: This method searches for a specific substring within a given string. 2. **Native `string.includes`**: This method checks if a specified value is present in a string. 3. **Lodash's `_indexOf`**: A custom implementation of the `indexOf` method using Lodash's utility functions. 4. **Lodash's `_includes`**: A custom implementation of the `includes` method using Lodash's utility functions. **Pros and Cons:** * Native methods: * Pros: Built-in, efficient, and well-optimized by the browser engine. * Cons: May not be as flexible or customizable as other implementations. * Lodash's `_indexOf` and `_includes`: * Pros: More flexible and customizable than native methods, with additional features like searching for multiple values. * Cons: May introduce overhead due to the use of a custom implementation. **Other considerations:** * The test case uses the `lodash.js` library, which provides various utility functions for string manipulation, among other things. In this context, it's used to provide custom implementations of the `indexOf` and `includes` methods. * There is no special JavaScript feature or syntax being tested in this benchmark. **Benchmark preparation code:** The script preparation code defines a test string `_str`, which contains various URL parameters and an object with a property named `{utms}`. The HTML preparation code includes the Lodash library, specifically the `lodash.min.js` file, to provide access to the `_indexOf` and `_includes` functions. **Latest benchmark results:** The provided data shows the execution rates for each test case across different browsers and devices. This allows users to compare the performance of native methods with their custom Lodash implementations. In terms of alternatives, other JavaScript libraries or frameworks (like jQuery) might offer similar string manipulation functionality. However, MeasureThat.net's focus on measuring the performance of specific strings operations makes it an ideal platform for comparing different implementation approaches.
Related benchmarks:
IndexOf vs Includes -- Strings
Substring in a string: IndexOf vs Includes vs lodash includes
IndexOf vs Includes vs lodash includes for string
lodash _.indexOf vs native indexOf with strings
Comments
Confirm delete:
Do you really want to delete benchmark?