Optimizing regular expression part 2
If you look at this post, you can see that I had some performance problem with regular expression. After the first round of optimization it turns out that performances are still quite slow. My next step will be to remove regular expression doing search by a custom algorithm.
I need to search word in text with the possibility to specify wildcards like Sampl?, or Samp*. This kind of search is really simple with regular expression, but is slow. I suspected that doing manual search with indexOf could be quicker. In few minutes I created a new component that uses indexof, fire all test, verify that the component is ok, and then I fire again the text against a big file. Doing a series of tests with the original optimized regex object returns.
|
|
Running the same suite of tests with the object that does not uses regex returns.
|
|
I’m quite happy, because I gain more than 70% performances with my first implementation that is the first think that comes in my mind. Now it is time again to fire DotTrace.
Since IndexOf is the one that occupies all the time, there is nothing more to optimize. Thanks to DotTrace I avoid wasting more time trying to optimize a function when all the time is spent in a framework function.
alk.