Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0
Chrome 130
Mac OS X 10.15.7
Desktop
one year ago
string.indexOf() !== -1
5.8M/s
text.includes()
5.8M/s
string.indexOf() != -1
5.7M/s
string.indexOf()
5.7M/s
regex.test()
4.0M/s
string.match()
3.5M/s
View exact numbers
Test name Executions per second
string.indexOf() !== -1 5,754,383 Ops/sec
text.includes() 5,750,376 Ops/sec
string.indexOf() != -1 5,749,165 Ops/sec
string.indexOf() 5,707,731 Ops/sec
regex.test() 4,020,917 Ops/sec
string.match() 3,467,184 Ops/sec
Script Preparation code:
Tests: