Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
slice vs capturing group
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser:
Chrome 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
slice
9212910.0 Ops/sec
groups
4234999.0 Ops/sec
Script Preparation code:
var IMAGE_SIZE_REGEX = /\/s\d{2,3}\//; var IMAGE_SIZE_REGEX_GROUPS = /(.+)?\/s\d{2,3}\/(.+)?/; function parseImageUrl(url) { const found = url.match(IMAGE_SIZE_REGEX); if (!found) { return null; } const { index } = found; const sizeStringLength = found[0].length; return { prefix: url.slice(0, index), suffix: url.slice(sizeStringLength + index), }; } function parseImageGroups(url) { const found = url.match(IMAGE_SIZE_REGEX_GROUPS); if (!found) { return null; } return { prefix: found[1], suffix: found[2], }; }
Tests:
slice
parseImageUrl('prefix/s480/suffix');
groups
parseImageGroups('prefix/s480/suffix');