indexOf vs lastIndexOf (v4)

Revision 4 of this benchmark created by Paul Miller on


Preparation HTML

<script>
  var s = "";
  for (var i = 0; i < 100; i++) {
   if (i === 33) s += "bar";
   else s += "foo"
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
s.indexOf("bar");
ready
lastIndexOf
s.lastIndexOf("bar", 0);
ready
indexOf (not found)
s.indexOf("test");
ready
lastIndexOf (not found)
s.lastIndexOf("test", 0);
ready

Revisions

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