.exec vs .match vs .test (v8)

Revision 8 of this benchmark created on


Description

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

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
Inline Test
if (/equator/.test(url)) {
 // Code Block
}
ready

Revisions

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