Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Longer regex test vs string includes
(version: 0)
Comparing performance of:
regex vs includes
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var string = "Helaas11111111111111111111111111111111111111111111111111111heljhell222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333343565555ghgfrdfdfdsfshellasdflasdkfjksadfksdflsdfjsdjlfjsdfkjadsfjakdsjfjsadlfklksdjflkjsdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddklllllllllllllllllllllllkkkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdfgafsdfsfdsadfsadfsadsadgfdgaesssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssHello world!"; var regex = /Hello/;
Tests:
regex
regex.test(string);
includes
string.includes("Hello");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
regex
includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
yesterday
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:150.0) Gecko/20100101 Firefox/150.0
Browser/OS:
Firefox 150 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
regex
11953529.0 Ops/sec
includes
2823768320.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview** The provided JSON represents a benchmark test case on MeasureThat.net, which compares the performance of two approaches to search for a specific string within a large input string: regular expression (regex) and string includes. **Benchmark Definition** The benchmark definition is not explicitly stated in the provided code. However, based on the test cases, it appears that the benchmark is comparing the performance of two functions: 1. `string.includes("Hello")`: This function checks if the input string "Hello" is present anywhere within the larger input string. 2. `regex.test(string)`: This function uses a regular expression to search for the pattern "Hello" within the larger input string. **Options Compared** The benchmark compares two options: 1. **String Includes**: Uses the `includes()` method to search for the presence of the substring "Hello" in the input string. 2. **Regular Expression**: Uses a regex pattern `/Hello/` to search for the exact match of the substring "Hello" in the input string. **Pros and Cons** **String Includes:** Pros: * Simple and easy to understand * Fast and efficient implementation Cons: * May not be suitable for searching complex patterns or regular expressions * Can be slower than regex for large inputs due to the overhead of iteration **Regular Expression:** Pros: * Powerful and flexible for searching complex patterns and regular expressions * Can be faster than string includes for large inputs due to the optimized engine Cons: * More complex and harder to understand, especially for beginners * May have slower performance due to the overhead of parsing and compiling the regex pattern **Other Considerations** * The input string is very large (333 characters), which may affect the performance of both options. * The test case uses a modern browser (Chrome 119) with a relatively high clock speed, which may impact the results. **Library and Purpose** In this benchmark, no explicit library is used. However, the `includes()` method is a built-in JavaScript function that searches for the presence of a substring within an input string. The regex pattern `/Hello/` is a simple regular expression that matches the exact substring "Hello". **Special JS Feature or Syntax** This benchmark uses the `includes()` method and regular expressions (regex), which are standard features in modern JavaScript. **Alternatives** If you were to design a similar benchmark, you could consider additional options, such as: * Using a different programming language or framework * Incorporating more complex patterns or regular expressions * Testing with different input sizes or distributions * Adding additional performance metrics, such as memory usage or CPU utilization.
Related benchmarks:
RegEx.test vs. String.includes vs. String.match insensitive
RegEx.test vs String.includes
Long regex test vs string includes
RegEx.test vs. String.includes 3
Comments
Confirm delete:
Do you really want to delete benchmark?