Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0
Chrome 123
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
indexOf === 0
26.7M/s
indexOf === 0 failure
26.4M/s
string .startsWith()
19.7M/s
string .startsWith() failure
19.7M/s
regexp .test() failure
17.6M/s
regexp .test()
17.5M/s
string .match() failure
14.5M/s
string .match()
14.2M/s
View exact numbers
Test name Executions per second
indexOf === 0 26,731,626 Ops/sec
indexOf === 0 failure 26,399,540 Ops/sec
string .startsWith() 19,714,600 Ops/sec
string .startsWith() failure 19,662,736 Ops/sec
regexp .test() failure 17,556,494 Ops/sec
regexp .test() 17,450,186 Ops/sec
string .match() failure 14,471,784 Ops/sec
string .match() 14,155,647 Ops/sec
Script Preparation code:
Tests: