test vs match

JavaScript performance comparison

Test case created by gdoron

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var numbersRegex = /^\d+$/
  var noWhiteSpaceRegex = /^\S*$/
  var positveIntegerRegex = /^[0-9]\d*$/
  
  var number = "234524543";
  var white = "545mmckdddjl..21][a/z''";
  var positiveInteger = "-423.123";
  var x = 0;

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
test
if (numbersRegex.test(number)) x++;

if (noWhiteSpaceRegex.test(white)) x++;

if (positveIntegerRegex.test(positiveInteger)) x++;
pending…
match
if (number.match(numbersRegex)) x++;

if (white.match(noWhiteSpaceRegex)) x++;

if (positiveInteger.match(positveIntegerRegex)) x++;
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.

0 Comments