Finding files faster

A little while back I wrote a pair of applications that used Path::Class::Rule to do the file finding. I selected this module because I like the interface for building up rules. I started to run into speed issues as the source directory grew larger and larger. Along comes rjbs's the speed of Perl file finders article and his speed chart backs up my findings that more files equals a marked increase in time.

This is where I found out about Path::Iterator::Rule which was just released by David Golden. It works the same as Path::Class::Rule but returns strings instead of objects, which gives a massive performance boost. Path::Iterator::Rule is a drop in replacement for Path::Class::Rule so updating my programs required very minor changes.

With Path::Class::Rule my application took an average of 66 seconds per run. Now the Path::Iterator::Rule version only takes 5 seconds with the same input. A full minute saved on each run, it feels good.

I am reminded of a quote from Brad Frost's article Performance As Design in which he states "Good performance is good design" and while the article context is web development, I think it applies to any kind of application.

1 Comment

I'm glad you're enjoying the speed boost. It's nice to know that my work is having real-world benefits for people. :-)

Leave a comment

About Kimmel

user-pic I like writing Perl code and since most of it is open source I might as well talk about it too. @KirkKimmel on twitter