.exec vs .match vs .test

JavaScript performance comparison

Revision 8 of this test case created

Info

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

Preparation code

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
.match()
if (url.match(rxTest) == "equator") {
 // Code Block
}
pending…
.exec()
if (rxTest.exec(url) == "equator") {
 // Code Block
}
pending…
.test()
if (rxTest.test(url)) {
 // Code Block
}
pending…
Inline Test
if (/equator/.test(url)) {
 // Code Block
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment