Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
regex test
(version: 0)
Test
Comparing performance of:
CharByChar vs Complete
Created:
9 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <link rel="stylesheet" href="style.min.css" type="text/css"> <link rel="stylesheet" href="style.min.css" type="text/css"> <link rel="stylesheet" href="style.min.css" type="text/css">
Tests:
CharByChar
var r = "execute addBtsCertificatePkcs /rom/config/pkcs.p12 IamThePassPhrase anything could be here"; return r.replace(/[p][k][c][s][.][p][1][2][ ]*(.+)/g, " <pkcs12 details removed>");
Complete
var r = "execute addBtsCertificatePkcs /rom/config/pkcs.p12 IamThePassPhrase anything could be here"; return r.replace(/pkcs\.p12 *(.+)/g, "pkcs.p12 <password removed>");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
CharByChar
Complete
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36
Browser/OS:
Chrome Mobile 130 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
CharByChar
916606.2 Ops/sec
Complete
882912.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON and explain what's being tested. **Benchmark Definition:** The benchmark definition is a set of instructions that defines how to run the test cases. In this case, it's relatively simple: * It loads jQuery 3.1.0 from an external source. * It links to three identical CSS files (`style.min.css`). * The script preparation code is empty. **Individual Test Cases:** There are two test cases defined in the benchmark: 1. **CharByChar**: This test case uses a regular expression (`[p][k][c][s][.][p][1][2][ ]*(.+)/g`) to replace characters by character from a string. The pattern matches any sequence of characters starting with "pkcs" and followed by an optional space and then one or more characters (captured in group 1). The replacement string is "<pkcs12 details removed>". Pros: * Easy to understand and modify. * Fast execution, as it only iterates over the match groups. Cons: * May not be suitable for larger patterns or strings. * May not cover all edge cases. 2. **Complete**: This test case uses a regular expression (`/pkcs\.p12 *(.+)/g`) that matches "pkcs.p12" followed by an optional space and then one or more characters (captured in group 1). The replacement string is "pkcs.p12 <password removed>". Pros: * More efficient than the `CharByChar` test case, as it only iterates over the captured group. * Covers a wider range of cases, including strings without the optional space. Cons: * May be slower due to the regular expression complexity. * Requires more careful handling of edge cases (e.g., strings with no match). **Library Usage:** The benchmark uses jQuery 3.1.0, which is an external library that provides additional functionality for DOM manipulation and event handling. In this case, it's likely used only for its utility functions. **Special JavaScript Feature/Syntax:** There are a few features used in the benchmark: * **Template literals**: The replacement strings use template literals (`"pkcs.p12 <password removed>"`) to insert variables. * **Regular expressions**: Both test cases use regular expressions to perform pattern matching and string manipulation. These features are supported by modern JavaScript engines, including Chrome 52, which is used in the benchmark. **Other Alternatives:** If you wanted to implement these tests using a different approach, here are some alternatives: 1. **String replacement without regular expressions**: You could use a simple loop to iterate over each character in the string and replace it individually. 2. **Manual string manipulation**: Instead of using regular expressions, you could write a custom function to manually manipulate the string by replacing characters one by one. 3. **Using a different library or framework**: Depending on your specific needs, you might choose to use a different library (e.g., a more efficient regex engine) or a different programming paradigm (e.g., using a functional programming approach). Keep in mind that these alternatives may have different performance characteristics and may require more maintenance effort.
Related benchmarks:
Test rgecg
regecx
regecxt
regecxgth
new RegExp test 2
Comments
Confirm delete:
Do you really want to delete benchmark?