Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
regex perf
(version: 0)
Comparing performance of:
big string regex match vs small string regex multiple match
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var str = 'my {id:name} is piyush{1} and your {id:name2} is rahul{2} and tere {id:chacha} is {id:shaktimaan} and discla {3}'
Tests:
big string regex match
var testString = (str+' | ').repeat(10000) var results =[...testString.matchAll(/\{(id:\w+)\}|\{(\d+)\}/gmi)]; var result = results.join('#')
small string regex multiple match
var testData = Array(10000).fill() var results = testData.map(item => { return [...str.matchAll(/\{(id:\w+)\}|\{(\d+)\}/gmi)]; }) var result = results.join('#')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
big string regex match
small string regex multiple match
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 is being tested on the provided JSON. **Benchmark Overview** The benchmark measures the performance of regular expression (regex) matching in JavaScript. The goal is to compare how different approaches, libraries, and even browsers perform when executing regex tests. **Options Compared** There are two main options compared: 1. **Single string vs. Multiple strings**: The first test case ("big string regex match") uses a single large string (`str`) as input, while the second test case ("small string regex multiple match") uses an array of small strings (`testData`). 2. **Browser Execution**: The benchmark compares the performance across different browsers (in this case, only Chrome 94). **Pros and Cons of Different Approaches** 1. **Single string vs. Multiple strings**: * Single string: This approach can be more straightforward to analyze, as it allows for a simpler regex pattern. * Multiple strings: However, this approach may introduce variability in the input data, making it harder to compare results across different browsers. 2. **Browser Execution**: Using multiple browsers can provide a broader understanding of how different implementations handle regex performance. However, this adds complexity and may require more testing to ensure accurate results. **Library Usage** In both test cases, the `str` variable is used as input for the regex matching tests. The `str` variable contains a template string with placeholders (`{id:name}`, `{id:name2}`, etc.) that are replaced with actual values when executed. This suggests that the library being tested is not necessarily the regex library itself but rather the JavaScript engine's handling of regular expressions. **Special JS Feature/Syntax** There are no obvious special JavaScript features or syntax used in these test cases. However, it's worth noting that the use of template literals (`str`) and the `repeat` method to create a large string may be specific to modern JavaScript engines. **Other Considerations** * The benchmark uses a simple regex pattern with two types of placeholders: `{id:name}` and `{(1|2)}`, which may not be representative of real-world use cases. * The benchmark does not account for other factors that might affect performance, such as the size of the input data or the complexity of the regex pattern. **Alternatives** Other alternatives to measure JavaScript performance could include: * CPU-intensive tasks, such as cryptographic calculations or scientific simulations * I/O-bound tasks, such as reading/writing files or network requests * Memory usage and garbage collection benchmarks * Web page rendering and animation benchmarks By considering these alternative approaches, software engineers can gain a more comprehensive understanding of their JavaScript application's performance characteristics.
Related benchmarks:
endsWith vs match for multiple strings
Regex Split Comparison
Regex First Name split vs match - no console
Test RegExp Performance
Comments
Confirm delete:
Do you really want to delete benchmark?