RegExp test / search / match vs. indexOf (v98)

Revision 98 of this benchmark created on


Preparation HTML

<script>
  var str = 'https://crm.zoho.com/crm/ShowHomePage.do?module=CustomModule1';
</script>

Setup

var precompiledRegex1 = /(http|https):\/\/.+\.(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak)/;
  var precompiledRegex2 = /(http|https):\/\/.+\.(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak).*/;
  var precompiledRegex3 = /^(http|https):\/\/.+\.(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak)/;
  var precompiledRegex4 = /^(http|https):\/\/.+\.(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak).*/;
  var precompiledRegex5 = /^(.*)(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak)/;
  var precompiledRegex6 = /^(.*)(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak).*/;
  var precompiledRegex7 = /^(.*)(facebook|youtube|yahoo|detik||kaskus|bukalapak|kompas|wordpress|tokopedia|okezone|twitter|blogspot|blogger|lazada|instagram|suara|olx|kompasiana|tempo|sindonews|tribunnews|merdeka|bintang|elevenia|republika|viva|rimanews|cliponyu|metrotvnews|kapanlagi|uzone|pulsk|beritasatu).*/;

Test runner

Ready to run.

Testing in
TestOps/sec
test
precompiledRegex1.test(str);
ready
search
precompiledRegex2.test(str);
ready
match
/^(.*)(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak)/.test(str);
ready
indexOf
precompiledRegex3.test(str);
ready
precompiled test
precompiledRegex4.test(str);
ready
precompiled search
precompiledRegex5.test(str);
ready
precompiled match
/^(.*)(facebook|youtube|yahoo|detik||kaskus|bukalapak|kompas|wordpress|tokopedia|okezone|twitter|blogspot|blogger|lazada|instagram|suara|olx|kompasiana|tempo|sindonews|tribunnews|merdeka|bintang|elevenia|republika|viva|rimanews|cliponyu|metrotvnews|kapanlagi|uzone|pulsk|beritasatu).*/.test(str);
ready
precompiled indexOf
precompiledRegex6.test(str);
ready
indexOf string primitive
precompiledRegex7.test(str);
ready
Primitive comparison
/(http|https):\/\/.+\.(facebook|youtube|yahoo|detik|liputan6|kaskus|tokopedia|bukalapak)/.test(str);
ready

Revisions

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