startsWith vs regexp vs indexOf (v21)

Revision 21 of this benchmark created on


Setup

var regexp = /^Lorem/;

Test runner

Ready to run.

Testing in
TestOps/sec
startsWith
if ('Lorem ipsum dolor sit amet'.startsWith('Lorem')) {}
ready
indexOf
if ('Lorem ipsum dolor sit amet'.indexOf('Lorem') === 0) {}
ready
RegExp
if (regexp.test('Lorem ipsum dolor sit amet')) {}
ready

Revisions

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