Pattern Matching Performance

Benchmark created on


Setup

const matchingString = "view capture has timed out (in someMethodName) after 1000ms with a threshold of 1000ms. Captured view may be incomplete!";

const _callerRegex = /(?<=view capture has timed out \(in )(.*)(?=\) after )/g;
const _elapsedTimeRegex = /(?<=\) after )(.*)(?=ms with a threshold of )/g;
const _thresholdRegex = /(?<=ms with a threshold of )(.*)(?=ms. Captured view may be incomplete!)/g;

const _pattern = /^view capture has timed out \(in ([\w]+)\) after (\d+)ms with a threshold of (\d+)ms./;

Test runner

Ready to run.

Testing in
TestOps/sec
lookback
const callerRegex = /(?<=view capture has timed out \(in )(.*)(?=\) after )/g;
const caller = matchingString.match(callerRegex)?.[0];
const elapsedTimeRegex = /(?<=\) after )(.*)(?=ms with a threshold of )/g;
const elapsedTime = matchingString.match(elapsedTimeRegex)?.[0];
const thresholdRegex = /(?<=ms with a threshold of )(.*)(?=ms. Captured view may be incomplete!)/g;
const threshold = matchingString.match(thresholdRegex)?.[0];
ready
cached-lookback
const caller = matchingString.match(_callerRegex)?.[0];
const elapsedTime = matchingString.match(_elapsedTimeRegex)?.[0];
const threshold = matchingString.match(_thresholdRegex)?.[0];

ready
single-pattern
const pattern = /^view capture has timed out \(in ([\w]+)\) after (\d+)ms with a threshold of (\d+)ms./;
const matches = matchingString.match(pattern);
ready
cached-single-pattern
const matches = matchingString.match(_pattern);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.