Regex Performance Testing (v7)

Revision 7 of this benchmark created on


Description

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

Setup

var pre_re = /^(a|abbr|address|area|article|aside|audio|b|base|bdi|bdo|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|data|datagrid|datalist|dd|del|details|dfn|dialog|div|dl|dt|em|embed|eventsource|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|head|header|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|main|mark|map|menu|menuitem|meta|meter|nav|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|ruby|rp|rt|s|samp|script|section|select|small|source|span|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|u|ul|var|video|wbr)$/;
    
    var post_re = new RegExp("^(a|abbr|address|area|article|aside|audio|b|base|bdi|bdo|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|data|datagrid|datalist|dd|del|details|dfn|dialog|div|dl|dt|em|embed|eventsource|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|head)$");

Test runner

Ready to run.

Testing in
TestOps/sec
Precompiled Regex (Replace)
pre_re.test("colgroup");
ready
Non-Precompiled Regex (Replace)
post_re.test("colgroup");
ready

Revisions

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