regexp vs indexOf (v163)

Revision 163 of this benchmark created on


Description

This time, we'll predefine the regex instead of re-declaring it with every iteration.

Preparation HTML

<script>
  var str = "hello world!",
      regex = /world/;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Regexp
str.match(regex);
ready
indexOf
str.indexOf("world") != -1;
ready
test
regex.test(str);
ready
indexof greater
str.indexOf('world')> -1;
ready
indexof greater
str.indexOf('world')> -1;
ready

Revisions

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