Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Precompile RegExp vs Runtime (on the fly)
Is precompile version faster then on runtime? Function toSpacePascalCase() convert 'someTextWith333Digits' to 'Some Text With 333 Digits'
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Precompile
1648323.2 Ops/sec
Runtime
1502985.0 Ops/sec
Script Preparation code:
const str = 'someTextWith333Digits' const p1 = /[a-z](?=\d)|\d(?=[a-z])/gi const p2 = /([A-Z]|([a-zA-Z]\d))/g const p3 = /^./ var toSpacePascalCasePrecompile = value => ( value // insert a space before/after number .replace(p1, '$& ') // insert a space before all caps .replace(p2, ' $1') // uppercase the first character .replace(p3, str => str.toUpperCase()) ) var toSpacePascalCaseRuntime = value => ( value // insert a space before/after number .replace(/[a-z](?=\d)|\d(?=[a-z])/gi, '$& ') // insert a space before all caps .replace(/([A-Z]|([a-zA-Z]\d))/g, ' $1') // uppercase the first character .replace(/^./, str => str.toUpperCase()) )
Tests:
Precompile
toSpacePascalCasePrecompile('someTextWith333Digits')
Runtime
toSpacePascalCaseRuntime('someTextWith333Digits')