Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
regex-vs-startswith
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
regex
15448784.0 Ops/sec
startsWith
52776428.0 Ops/sec
Script Preparation code:
window.baseAction = 'MY_ACTION' window.actionRegularExpression = /^MY_ACTION_(\w+)_(?<=_)(.*)$/i; window.baseString = 'MY_ACTION_QUESTION_START_my-first-question';
Tests:
regex
let [, action, id] = actionRegularExpression.exec(baseString)
startsWith
let action; let id; if(baseString.startsWith(baseAction)){ const lastUnderscore = baseString.lastIndexOf('_'); action = baseString.substring(baseAction.length + 1, lastUnderscore) id = baseString.substring(lastUnderscore + 1) }