Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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
Benchmark engine:
Benchmark.js
indexOf === 0
5.3M/s
string .startsWith()
3.4M/s
regexp .test()
2.7M/s
string .match()
2.4M/s
View exact numbers
Test name
Executions per second
✓
indexOf === 0
5,299,470 Ops/sec
string .startsWith()
3,358,415 Ops/sec
regexp .test()
2,664,296 Ops/sec
string .match()
2,427,510 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://')