regexp .test() vs indexOf (v134)

Revision 134 of this benchmark created on


Description

regex.test() vs indexOf()

Setup

var url = "https://www.google.ca/search?q=google+search+test&oq=google+search+test&aqs=chrome..69i57j0l5.4488j0j1&sourceid=chrome&es_sm=122&ie=UTF-8";
    
    var hashAlgorithm = "hmac-md5";

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
url.indexOf("chrome") !== 0;
hashAlgorithm.indexOf("hmac") !== -1;
ready
test()
!/^chrome/i.test(url);
/hmac/i.test(hashAlgorithm);
ready
test() + brackets
!(/^chrome/i).test(url);
(/hmac/i).test(hashAlgorithm);
ready

Revisions

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