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:
8 months ago
by:
Guest
Go 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:
8 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
Indexed
2524.1M/s
startsWith
2377.4M/s
regex
64.7M/s
View exact numbers
Test name
Executions per second
✓
Indexed
2,524,114,944 Ops/sec
startsWith
2,377,367,808 Ops/sec
regex
64,739,104 Ops/sec
Related benchmarks
Array.includes vs String.match
String.includes vs String.match 2
Array manual search vs Regex.test
Array manual search vs Regex.test (2)
Comments
Confirm delete:
Do you really want to delete benchmark?