Case insensitive vs case sensitive regex (v5)

Revision 5 of this benchmark created on


Description

Test performance impact on micro optimazation for regex in strings

Setup

var lowercase = 'this is a string!',
        mixedcase = 'This iS a StRinG!',
        rxLowercase = /string/,
        rxMixedcase = /string/i,
        match;

Test runner

Ready to run.

Testing in
TestOps/sec
Case insensitive regular expression
match = /string/i.test(mixedcase);
ready
Case sensitive regular expression
match = /string/.test(lowercase);
ready
Case insensitive regular expression (shared regex)
match = rxMixedcase.test(mixedcase);
ready
Case sensitive regular expression (shared regex)
match = rxLowercase.test(lowercase);
ready
Case sensitive regular expression (on the fly lowercase)
match = /string/.test(mixedcase.toLowerCase());
ready
Case sensitive regular expression (shared regex & on the fly lowercase)
match = rxLowercase.test(mixedcase.toLowerCase());
ready

Revisions

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