substring test (v2)

Revision 2 of this benchmark created by regexp or indexof on


Preparation HTML

<script>
  var str = "This is a simple test";
  var needle = "simple";
  var r = new RegExp('simple');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
regex
var c = /simple/.test(str)
ready
indexof
var c = str.indexOf(needle) > -1
ready
RegExp
var c = (new RegExp(needle)).test(str);
ready
just RegExp with modifier
var c = RegExp('Simple', 'i').test(str);
ready

Revisions

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