regexp .test() vs indexOf (v133)

Revision 133 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
indexOf1
url.indexOf("chrome") !== 0;
ready
.test 1
!/^chrome/i.test(url);
ready
.test 1 + brackets
!(/^chrome/i).test(url);
ready
.indexOf 2
hashAlgorithm.indexOf("hmac") !== -1;
ready
.test 2
/hmac/i.test(hashAlgorithm);
ready
.text 2 + brackets
(/hmac/i).test(hashAlgorithm);
ready

Revisions

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