ParseGenericArguments IsMatch is very slow
------------------------------------------

                 Key: IBATISNET-270
                 URL: https://issues.apache.org/jira/browse/IBATISNET-270
             Project: iBatis for .NET
          Issue Type: Improvement
          Components: DataMapper
    Affects Versions: DataMapper 1.6.1
            Reporter: Michael Schall


I knew .* is expensive in regular expressions, but I had no idea how expensive! 
 In our application when ConfigureAndWatch is called, the IsMatch function call 
within ParseGenericArguments is taking 5000ms (reported by dotTrace).  The 
method is called 1005 times at 5ms a piece.  By simply removing the .* from the 
beginning of the regular expression, the time is brought down to a total of 4ms 
(not per call, total)!  I also made the RegEx object a static of the class so 
we aren't re-creating the expression for each call to bring the total time down 
to 2ms!   I'll attach 2 images of the before and after traces if I can.

Please check my work...  I have tested it with my app and everything works fine.

Mike

I will include the patch here:

            private readonly static Regex _generic = new Regex(@"`\d*\[\[", 
RegexOptions.Compiled);

            private void ParseGenericArguments(string originalString)
            {
                // Check for match
                bool isMatch = _generic.IsMatch(originalString);

                if (!isMatch)


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to