regexp vs indexOf (v149)

Revision 149 of this benchmark created on


Preparation HTML

<script>
  var str1 = "";
  var str2 = "static";
  var str3 = "relative";
  var str4 = "none";
</script>

Setup

var test_regex = /\s|relative|static/;

Test runner

Ready to run.

Testing in
TestOps/sec
Regexp
test_regex.test(str1);
test_regex.test(str2);
test_regex.test(str3);
test_regex.test(str4);
ready
indexOf
["", "static", "relative"].indexOf(str1) === -1;
["", "static", "relative"].indexOf(str2) === -1;
["", "static", "relative"].indexOf(str3) === -1;
["", "static", "relative"].indexOf(str4) === -1;
ready

Revisions

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