test or match regexp or indexOf (v2)

Revision 2 of this benchmark created on


Description

Which is better: test() or match()

Test runner

Ready to run.

Testing in
TestOps/sec
test
var href = "http://www.my-website.com/folder/file.html?par1=hello",
    times = 1000;

while (times--) {
  /par\d/.test(href);
}
ready
match
var href = "http://www.my-website.com/folder/file.html?par1=hello",
    times = 1000;

while (times--) {
  href.search(/par\d/);
}
ready
indexOf
var href = "http://www.my-website.com/folder/file.html?par1=hello",
    times = 1000;

while (times--) {
  href.indexOf("par");
}
ready

Revisions

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