regexp vs indexOf (v61)

Revision 61 of this benchmark created by fgsfds on


Description

the further the string to match, the faster regexp is

Preparation HTML

<script>
  var s = 'collapsedContentLink;;http://ad.doubleclick.net/clk;260736037;45570551;f?http://ad.doubleclick.net/click;h=v2|3FEF|0|0|%2a|o;264355298;0-0;0;90019447;31-1|1;51059432|51029275|1%3B%3B;pc=DFP%eaid!%3fhttps://www.discover.com/credit-cards/cashback-bonus/cashback-calendar.html,expandedContentLink;;http://ad.doubleclick.net/clk;260736037;45570551;f?http://ad.doubleclick.net/click;h=v2|3FEF|0|0|%2a|o;264355298;0-0;0;90019447;31-1|1;51059432|51029275|1%3B%3B;pc=DFP%eaid!%3fhttps://www.discover.com/credit-cards/cashback-bonus/cashback-calendar.html,main;;http://ad.doubleclick.net/clk;260736037;45570551;f?http://ad.doubleclick.net/click;h=v2|3FEF|0|0|%2a|o;264355298;0-0;0;90019447;31-1|1;51059432|51029275|1%3B%3B;pc=DFP%eaid!%3fhttps://www.discover.com/credit-cards/cashback-bonus/cashback-calendar.html',
 str = '', i = 1000;
 while (i--) str += s;
 str += "hello world!";
</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.