test vs match (v6)

Revision 6 of this benchmark created on


Setup

var numbersRegex = new RegExp('^\d+$');
    var noWhiteSpaceRegex = new RegExp('^\S*$');
    var positveIntegerRegex = new RegExp('^[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
exec
if (numbersRegex.exec(number)) x++;

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

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

Revisions

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