match vs startsWith vs test

Benchmark created on


Setup

const prefixRe = /^\$con:/;

const statements = [
"$con: 30.2859561 , -97.751166600000000",
"$con:30.2859561 , -97.751166600000000",
"$con:30.2859561,-97.751166600000000",
"$con: 42.75508649805567 , -83.15661443489478",
"$con:42.75508649805567 , -83.15661443489478",
"$con:42.75508649805567,-83.15661443489478",
]

Test runner

Ready to run.

Testing in
TestOps/sec
match
statements.filter(
      (statement) => statement.match(/^\$con:/)
    );
ready
startsWith
statements.filter(
      (statement) => statement.startsWith("$con:")
    );
ready
test
statements.filter(
      (statement) => prefixRe.test(statement)
    );
ready

Revisions

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