Re vs string

Benchmark created on


Setup

 var pathname = 'history/foo?bar=baz#olo'

Test runner

Ready to run.

Testing in
TestOps/sec
RE
/^\/?history/.test(pathname)
ready
String secondMatch
pathname.startsWith('/history') || pathname.startsWith('history');
ready
String firstMatch
pathname.startsWith('history') || pathname.startsWith('/history');
ready

Revisions

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