RegExp test / search / match vs. indexOf / substr (v64)

Revision 64 of this benchmark created by Luke Bonaccorsi on


Preparation HTML

<script>
  var str = 'profile-test';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
test
/^profile-/.test(str);
ready
search
str.search(/^profile-/) > -1;
ready
match
str.match(/^profile-/).length > 0;
ready
indexOf
str.indexOf('profile-') > -1;
ready
substr
str.substr(0, 8) === 'profile-';
ready

Revisions

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