Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
CORS Test
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Regex: Valid Cases
1063379.6 Ops/sec
Regex: Invalid Cases
2530043.8 Ops/sec
Procedural: Valid Cases
447856.0 Ops/sec
Procedural: Invalid Cases
442045.7 Ops/sec
Script Preparation code:
// For accuracy declare the regex in root scope // assume this tester doesnt rerun the setup on each test case const DOMAIN_TO_LOCALE = Object.freeze({ com: 'en-us', dk: 'da', de: 'de', fr: 'fr-fr', no: 'nb', pt: 'pt', se: 'sv', 'com.br': 'pt-br', 'com.es': 'es', }); const FOO_VALID_TLDS = Object.keys(DOMAIN_TO_LOCALE).join('|'); const FOO_DOMAIN_REGEX = new RegExp( `^https://(?:[\\w-]+\\.)*foo\\.(?:${FOO_VALID_TLDS})\\.?(?::[\\d]{1,5})?$` ); function checkRegex(url) { return FOO_DOMAIN_REGEX.test(url) } function checkProcedural(url) { const { protocol, hostname } = new URL(url); const [subdomain, tld] = hostname.split('foo.'); if (typeof tld === 'undefined') return; const isSecure = protocol.startsWith('https'); const isValidTld = tld in DOMAIN_TO_LOCALE; return isSecure && isValidTld; } window.validCases = [ 'https://foo.com', 'https://bar.foo.com', 'https://foo.bar.foo.com', 'https://BAR.foo.com', 'https://-_47.foo.com', 'https://foo.foo.com', 'https://foo.com:1', 'https://foo.com:65535', 'https://foo.com.', 'https://foo.com.:47', 'https://foo.fr', 'https://develop.foo.fr', 'https://develop.nested.foo.fr', 'https://develop.nested.foo.com.es', ]; window.invalidCases = [ 'https://foo.com.fake.com', 'https://foo.com.org', 'https://foofoo.com', 'file://foo.com', 'http://foo.com', 'https://.foo.com', ];
Tests:
Regex: Valid Cases
validCases.every(url => checkRegex(url));
Regex: Invalid Cases
invalidCases.every(url => !checkRegex(url));
Procedural: Valid Cases
validCases.every(url => checkProcedural(url));
Procedural: Invalid Cases
invalidCases.every(url => !checkProcedural(url));