Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Performance checking the start of a string
(version: 1)
Comparing performance of:
Indexed vs startsWith vs regex
Created:
5 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Tests:
Indexed
const subject = '--foo'; subject[0] === '-' && subject[1] === '-' && subject.length > 2 && subject[2] !== '-';
startsWith
const subject = '--foo'; subject.startsWith('--') && subject.length > 2 && subject[2] !== '-';
regex
const subject = '--foo'; const pattern = /^--[^-]/; subject.match(pattern);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Indexed
startsWith
regex
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser/OS:
Firefox 145 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Indexed
2524114944.0 Ops/sec
startsWith
2377367808.0 Ops/sec
regex
64739104.0 Ops/sec
Related benchmarks:
Array.includes vs String.match
Array.includes vs String.match
String.includes vs String.match 2
String.includes vs String.match 3
String.match vs String.includes
Array.includes vs String.match, single pattern
String.includes vs String.match vs String.indexOf
Array manual search vs Regex.test
Array manual search vs Regex.test (2)
Comments
Confirm delete:
Do you really want to delete benchmark?