test vs match

Benchmark created by gdoron on


Setup

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;

Test runner

Ready to run.

Testing in
TestOps/sec
test
if (numbersRegex.test(number)) x++;

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

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

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

if (positiveInteger.match(positveIntegerRegex)) x++;
ready

Revisions

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