After profiling the DailyProjectFileMetric class and finding that half of its 
time is spent in the stupid Ant file pattern matching algorithm, I implemented 
a new method called matches2(String) in the FilePattern class.  The idea behind 
this version of matches(String) is that if you have an application scenario in 
which most of your FilePatterns represent "top-level" patterns (such as 
"hackyCore_Kernel/**", etc.), then there's no need to invoke the heavy-weight 
pattern matching infrastructure: you can figure out with a few for loops if the 
darn thing matches or not. 

I've just committed the changes, it cut the runtime of DailyProjectFileMetric 
in half, and now the major time in the algorithm (40%) is spent in the 
toLowerCase() method.  This is time I'm willing to pay for since it means that 
people don't have to worry about the case of their metric names (i.e. 
"totalLines" vs. "TotalLines" vs. "totallines"). 

Oh, and as a result, the new version of DailyProjectFileMetrics is now just 
about the same speed as the old one.   

Cheers,
Philip

Reply via email to