Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
regex test123123d
(version: 0)
Comparing performance of:
event regex vs case data
Created:
6 years ago
by:
Guest
Jump to the latest result
Tests:
event regex
const envRegex = /\^[a-zA-Z0-9_]+\b/g; const dataRegex = /\$[a-zA-Z0-9_]+\b/g; const dataenvRegex = /(\$|\^)[a-zA-Z0-9_]+\b/g; const eventRegex = /\@[a-zA-Z0-9_]+(?:\.[a-zA-Z0-9_]+|\b)(?:\b\[(#|\.)[a-zA-Z0-9_-]+\]|\b)/g; const str = " background-color: #f7f7f7; opacity: [[ $pageopacity ]]; --r-nonexistentvalue: [[ $noexist ]]; --r-somevar: [[ $somevar ]]; --someevent: [[ @mousemove.clientX[#myelement] ]]; --r-mx: [[ &add(&num(^mouse_clientX), &add(101px,22), 60) ]]px; --r-my: [[ &sub(^mouse_clientY, 20) ]]px;"; str.match(eventRegex);
case data
const envRegex = /\^[a-zA-Z0-9_]+\b/g; const dataRegex = /\$[a-zA-Z0-9_]+\b/g; const dataenvRegex = /(\$|\^)[a-zA-Z0-9_]+\b/g; const eventRegex = /\@[a-zA-Z0-9_]+(?:\.[a-zA-Z0-9_]+|\b)(?:\b\[(#|\.)[a-zA-Z0-9_-]+\]|\b)/g; const str = " background-color: #f7f7f7; opacity: [[ $pageopacity ]]; --r-nonexistentvalue: [[ $noexist ]]; --r-somevar: [[ $somevar ]]; --someevent: [[ @mousemove.clientX[#myelement] ]]; --r-mx: [[ &add(&num(^mouse_clientX), &add(101px,22), 60) ]]px; --r-my: [[ &sub(^mouse_clientY, 20) ]]px;"; str.match(dataRegex);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
event regex
case data
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 what's being tested in the provided JSON. **Benchmark Definition** The benchmark definition is an object that defines a JavaScript microbenchmark. It consists of: 1. **Script Preparation Code**: An empty string, indicating no script preparation code is required for this benchmark. 2. **Html Preparation Code**: An empty string, indicating no HTML preparation code is required for this benchmark. **Individual Test Cases** There are two individual test cases defined in the JSON: 1. **"event regex"`** This test case uses a regular expression to match a specific string pattern. The regular expression is: ```javascript const eventRegex = /\\@[a-zA-Z0-9_]+(?:\\.[a-zA-Z0-9_]+|\\b)(?:\\b\\[(#|\\.)[a-zA-Z0-9_-]+\\]|\\b)/g; ``` This regular expression matches a string that starts with `@` followed by one or more alphanumeric characters, optionally followed by a dot and another alphanumeric character. The pattern also allows for an optional array index (`[#...]`) within the match. The test case uses the `match()` method to find any occurrences of this pattern in a given string: ```javascript const str = " background-color: #f7f7f7; opacity: [[ $pageopacity ]]; --r-nonexistentvalue: [[ $noexist ]]; --r-somevar: [[ $somevar ]]; --someevent: [[ @mousemove.clientX[#myelement] ]]; --r-mx: [[ &add(&num(^mouse_clientX), &add(101px,22), 60) ]]px; --r-my: [[ &sub(^mouse_clientY, 20) ]]px;"; str.match(eventRegex); ``` 2. **"case data"`** This test case uses another regular expression to match a specific string pattern: ```javascript const dataRegex = /\\$[a-zA-Z0-9_]+\\b/g; ``` This regular expression matches a dollar sign followed by one or more alphanumeric characters. The test case uses the `match()` method to find any occurrences of this pattern in a given string: ```javascript const str = " background-color: #f7f7f7; opacity: [[ $pageopacity ]]; --r-nonexistentvalue: [[ $noexist ]]; --r-somevar: [[ $somevar ]]; --someevent: [[ @mousemove.clientX[#myelement] ]]; --r-mx: [[ &add(&num(^mouse_clientX), &add(101px,22), 60) ]]px; --r-my: [[ &sub(^mouse_clientY, 20) ]]px;"; str.match(dataRegex); ``` **Library and Special Features** * The regular expressions used in these test cases are not part of any specific library. They are standard JavaScript built-in features. * There are no special features or syntax being tested in these benchmarks. **Alternatives** The primary alternative to running this benchmark is to write a similar test case using a different approach, such as: * Using a regular expression testing tool like [Regex101](https://regex101.com/) * Writing a custom test harness to measure the performance of the `match()` method on the given strings * Running the benchmark using a JavaScript runtime that provides built-in support for regular expression matching, such as Google Chrome's V8 engine Keep in mind that the accuracy and reliability of these alternatives depend on the specific requirements and constraints of your project.
Related benchmarks:
.test vs .match vs modulo(string)
regex 0001 + 1
regex 0001 + 4
parseFloat isNaN vs RegEx parseFloat
parseFloat isNaN vs RegEx parseFloat vs Number isNaN
Comments
Confirm delete:
Do you really want to delete benchmark?