regexp vs indexOf (v41)

Revision 41 of this benchmark created by ariel on


Description

I've increased the text size, since in real life scenarios you usually search for short patterns in a substancially longer text.

Preparation HTML

<script>
  var str = "hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test. hello world! This is a longer, albit fixed, text, with hello world! repeaded in it several time. The text itself is repeated by copy and paste, in hope that it will result in a better test.";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Regexp
str.match(/world/);
ready
indexOf
str.indexOf("world");
ready

Revisions

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