ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Schall (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Created: (IBATISNET-270) ParseGenericArguments IsMatch is very slow
Date Thu, 05 Jun 2008 19:49:46 GMT
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.


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.

View raw message