Regex Performance Testing (v8)

Revision 8 of this benchmark created on


Description

How much faster is a precompiled regex vs a non-precompiled regex?

Setup

var preCompiledReplaceRegex = /^(\d{4})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/; 
    
    myHtml = "2013-02-03";

Test runner

Ready to run.

Testing in
TestOps/sec
Precompiled Regex (Replace)
myHtml.match(preCompiledReplaceRegex);
ready
Non-Precompiled Regex (Replace)
myHtml.match(new RegExp('^(\\d{4})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$'));
ready

Revisions

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