substring vs regex (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  string1 = "itemView";
  string2 = "yourMom";
  
  item = "item";
  regex = /^item/ig;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
regex
regex.test(string1);
regex.test(string2);
ready
substring
string1.substring(0, 4) == item;
string2.substring(0, 4) == item;
ready

Revisions

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