String starts with single char

Benchmark created on


Setup

const str = 'a'.repeat(1000) + 'b'.repeat(1000) + 'c'.repeat(1000) + 'd';

Test runner

Ready to run.

Testing in
TestOps/sec
.startsWith Best Case
str.startsWith('a')
ready
.startsWith Worst Case
str.startsWith('d')
ready
indexer Best Case
str[0] === 'a'
ready
indexer Worst Case
str[0] === 'd'
ready
indexOf Best Case
str.indexOf('a') === 0
ready
indexOf Worst Case
str.indexOf('d') === 0
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.