Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
.startsWith() vs .test() vs .match() vs .indexOf()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
Browser:
Opera 95
Operating system:
Windows 7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
regexp .test()
1359891.4 Ops/sec
string .match()
1665560.6 Ops/sec
indexOf === 0
3428982.5 Ops/sec
string .startsWith()
2082480.1 Ops/sec
Script Preparation code:
var html = "https://www.google.com";
Tests:
regexp .test()
/^https?:\/\//.test(html)
string .match()
!!html.match(/^https:\/\//)
indexOf === 0
html.indexOf('http://') === 0
string .startsWith()
html.startsWith('https://')