RegExp test / search / match vs. indexOf

JavaScript performance comparison

Revision 17 of this test case created by

Preparation code

<script>
  var str = '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';
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var precompiledRegex = /discover.com/;

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
test
/discover.com/.test(str);
pending…
search
str.search(/discover.com/) > -1;
pending…
match
str.match(/discover.com/).length > 0;
pending…
indexOf
str.indexOf(/discover.com/) > -1;
pending…
precompiled test
precompiledRegex.test(str);
pending…
indexOf string
str.indexOf('discover.com') > -1;
pending…

Compare results of other browsers

Revisions

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

0 Comments