.exec vs .match vs .test

Benchmark created by Kyle A. Matheny on


Description

Test case to determine which code is fastest at detecting a pattern within the URL.

Preparation HTML

<script>
  var rxTest = /equator/,
      url = "http://www.equator.com/";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
.match()
if (url.match(rxTest) == "equator") {
 // Code Block
}
ready
.exec()
if (rxTest.exec(url) == "equator") {
 // Code Block
}
ready
.test()
if (rxTest.test(url)) {
 // Code Block
}
ready

Revisions

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