in reply to sizeDateValidator.pl is horribly slow

Checking 20000 files in 3 minutes means you do more than 100 stat checks per second (actually you do double that number because you stat twice for each file) many even on a server link. I think that is pretty fast.

What kind of performance were you expecting?

Update:

I ran a little test myself.

use Modern::Perl; use Time::HiRes qw/time/; open my $LIST, '<', 'M:/YP/list.txt' or die $!; my @stats; my $start = time; while (<$LIST>) { chomp; push @stats, stat "M:/YP/$_"; } my $end = time; say 'stat checks took ', $end - $start, ' seconds.'; say 'That is ', 540 / ($end - $start), ' checks per second.';
I am checking 540 existing files myself over my local network (the "M" drive is on a NAS) and got about 54 stat checks per second. So your performance is actually quite good!

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: sizeDateValidator.pl is horribly slow
by Anonymous Monk on Nov 06, 2011 at 17:25 UTC
    Thanks Monks! I'm going to go with the suggestion for the single stat call, and let you know how much faster it runs. I wont be back in this environmen til tomorrow but should get time to do it then. BTW, my goal was to have it run in less than a minute, but sounds like that may have been wishful thinking. If I can get it down to < 2 min I'll be happy.