<?xml version="1.0" encoding="windows-1252"?>
<node id="1006068" title="Re: Speed of Perl Regex Engine" created="2012-11-28 11:23:43" updated="2012-11-28 11:23:43">
<type id="11">
note</type>
<author id="616540">
moritz</author>
<data>
<field name="doctext">
&lt;blockquote&gt;The reports for those banks do take noticeably longer to produce than when the system first went online&lt;/blockquote&gt;

&lt;p&gt;That sounds as if lots of stuff might have been changed in between. Run a [mod://Devel::NYTProf|profiler] over the script(s) and see where the time is actually spent.&lt;/p&gt;

&lt;blockquote&gt; I don't have much knowledge of or feel for the performance of the Perl Regex engine. Is it linear, like will it take ten times as long to match against a 600-character Regex than against a 60-character one?&lt;/blockquote&gt;

&lt;p&gt;In general, it doesn't depend much on the length of regex, but on the amount of backtracking and searching that the regex engine has to do.&lt;/p&gt;

&lt;p&gt;If it's just a big alternation of constant strings, and you use perl 5.10.0 or newer, the trie optimization in the regex engine should handle that case very well (sub-linear even). If your regex grows too big, try increasing [doc://${^RE_TRIE_MAXBUF}] -- but only if it's the regex that's actually slow.&lt;/p&gt;

&lt;p&gt;And as already mentioned, if you can solve your problem through a hash lookup, that would be even better.&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-616540"&gt;
[http://perl6.org/|Perl 6 - the future is here, just unevenly distributed]
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1006062</field>
<field name="parent_node">
1006062</field>
</data>
</node>
