Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
with/without regex
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/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
with regexp
242659.7 Ops/sec
without
243238.8 Ops/sec
Tests:
with regexp
function getDisplayName(definitionName, checkBundleId = true) { let displayName; const name = definitionName || ''; if (checkBundleId) { const bundleId = getBundleId(definitionName); displayName = name.substring(name.lastIndexOf(':') + 1); } else { displayName = name.substring(name.lastIndexOf(':') + 1); } return displayName; } function getBundleId(definitionName) { const name = definitionName || ''; const matches = name.match(/(.+):/); return (matches && matches.pop()) || ''; } const res = getDisplayName('foo:bar'); console.log(res);
without
function getDisplayName(definitionName, checkBundleId = true) { let displayName; const name = definitionName || ''; if (checkBundleId) { const bundleId = getBundleId(definitionName); displayName = name.substring(name.lastIndexOf(':') + 1); } else { displayName = name.substring(name.lastIndexOf(':') + 1); } return displayName; } function getBundleId(definitionName) { const name = definitionName || ''; const matches = name.split(':')[0]; return matches || ''; } const res = getDisplayName('foo:bar'); console.log(res);