Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
indexOf vs startsWidth vs includes
compare javascript string matching options
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
indexOf (start)
4K/s
indexOf (end)
4K/s
includes (end)
4K/s
includes (start)
4K/s
startsWith (end)
3K/s
startsWith (start)
2K/s
View exact numbers
Test name
Executions per second
✓
indexOf (start)
3,732 Ops/sec
indexOf (end)
3,729 Ops/sec
includes (end)
3,709 Ops/sec
includes (start)
3,705 Ops/sec
startsWith (end)
3,430 Ops/sec
startsWith (start)
2,292 Ops/sec
Script Preparation code:
var sub = "(sub)"; var textsStart = []; var textsEnd = []; for(var i = 0; i < 10000; i++) { textsStart.push(`${sub} My ${i} test sample which contains sub at the end`) textsEnd.push(`My ${i} test sample which contains sub at the end ${sub}`) }
Tests:
indexOf (start)
for(const textStart of textsStart) textStart.indexOf(sub)
indexOf (end)
for(const textEnd of textsEnd) textEnd.indexOf(sub)
startsWith (start)
for(const textStart of textsStart) textStart.startsWith(sub)
startsWith (end)
for(const textEnd of textsEnd) textEnd.startsWith(sub)
includes (start)
for(const textStart of textsStart) textStart.includes(sub)
includes (end)
for(const textEnd of textsEnd) textEnd.includes(sub)