Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
getRelativeUrl
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0
Browser:
Firefox 121
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
new URL
516661.4 Ops/sec
RegExp
2104206.5 Ops/sec
getRelativeUrl
10841757.0 Ops/sec
Script Preparation code:
function getRelativeUrl(url) { try { if (url.indexOf('http://') > -1) { return url.substring(url.indexOf('/', 7) + 1); } if (url.indexOf('https://') > -1) { return url.substring(url.indexOf('/', 8) + 1); } throw new Error('invalid url'); } catch (e) { console.error(e); return url; } };
Tests:
new URL
return new URL('https://is5-ssl.mzstatic.com/image/thumb/Purple126/v4/00/33/2e/00332e58-b196-82cf-1231-82d81d6fe477/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/512x0w.png').origin;
RegExp
return 'https://is5-ssl.mzstatic.com/image/thumb/Purple126/v4/00/33/2e/00332e58-b196-82cf-1231-82d81d6fe477/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/512x0w.png'.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)(\/[^?#]*)?(\?[^#]*)?/)[0]
getRelativeUrl
return getRelativeUrl('https://is5-ssl.mzstatic.com/image/thumb/Purple126/v4/00/33/2e/00332e58-b196-82cf-1231-82d81d6fe477/AppIcon_TikTok-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/512x0w.png')