RegExp test / search / match vs. indexOf (v15)

Revision 15 of this benchmark created by Michael Sherov on


Description

Testing for the existence of characters in a string using Regular Expressions test, search, and match compared to indexOf.

Preparation HTML

<script>
  var str = 'body';
</script>

Setup

var precompiledRegex = /^(inline|ruby)/;

Test runner

Ready to run.

Testing in
TestOps/sec
regex
precompiledRegex.test(str);
ready
comparison
str === "inline" || str === "inline-block" || str === "inline-table" || str === "ruby";
ready

Revisions

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