Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
RegEx.test vs. String.includes vs. String.match vs == .slice
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
startsWith
1856.7M/s
String.includes
1767.4M/s
==
1766.8M/s
=== known length
1756.9M/s
RegEx.test
36.1M/s
String.match
13.5M/s
View exact numbers
Test name
Executions per second
✓
startsWith
1,856,660,224 Ops/sec
String.includes
1,767,422,720 Ops/sec
==
1,766,788,480 Ops/sec
=== known length
1,756,921,216 Ops/sec
RegEx.test
36,107,548 Ops/sec
String.match
13,541,992 Ops/sec
Script Preparation code:
var string = "Hello world!"; var regex = /Hello/;
Tests:
RegEx.test
regex.test(string);
String.includes
string.includes("Hello");
String.match
string.match("Hello");
==
"Hello" == string.slice(0, "Hello".length);
=== known length
string.slice(0, 5) === "Hello"
startsWith
string.startsWith("Hello")