On 06/18/2013 01:53 PM, Gary Willoughby wrote:
Below is an example snippet of code to test for performance of regex
matches. I need to parse a large log and extract data from it and i've
noticed a huge increase in time of the loop when reading and using regex.

     ...
     auto alert = regex(r"^Alert ([0-9]+)");

     while ((line = file.readln()) !is null)
     {
         auto m = match(line, alert);

         if (m)
         {
             alerts++;
         }

         counter++;
     }
     ...

Using the above example i parse about 700K lines per second (i'm reading
from an SSD). If i comment out the regex match function, i read at 4.5M
lines per second. Considering i need to use about 8 regex matches and
extract data, this figure further drops to about 100K lines per second.

Is there anything i can do to speed up regex matching in such a
scenario? Are there any tips you can share to speed things up?

Thanks.

enum alert = ctRegex!r"^Alert ([0-9]+)";

And then use it the same way.

Reply via email to