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

Revision 2 of this benchmark created on


Preparation HTML

<script>
  var str = 'Hello, world.';
</script>

Test runner

Ready to run.

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

Revisions

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