Re vs string (v2)

Revision 2 of this benchmark created on


Setup

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

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
Cached RE
cachedRe.test(pathname)
ready

Revisions

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