regexp .test() vs indexOf (v132)

Revision 132 of this benchmark created on


Description

regex.test() vs indexOf()

Setup

var url = "http://jsperf.com/regexp-vs-indexof/";
    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.