regex vs startsWith

Benchmark created on


Setup

const a = "2.2.840.10008.5.1.4.1.1.77.1.1"

Test runner

Ready to run.

Testing in
TestOps/sec
regex
a.match(/^1\.2\.840\.10008\.5\.1\.4\.1\.1\.7\.?/)
ready
StartsWith
a === "1.2.840.10008.5.1.4.1.1.7" || a.startsWith('1.2.840.10008.5.1.4.1.1.7.')
ready
IndexOf
a === "1.2.840.10008.5.1.4.1.1.7" || a.indexOf('1.2.840.10008.5.1.4.1.1.7.') === 0
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.