Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a faster alternative to Perl's stat?

I'm traversing an entire partition, stat()'ing each file and then checking the returned values for mtime, size and uid against hashed values. stat() however is far too slow in Perl and I'm wondering if there's any quicker alternatives I may be overlooking.

like image 960
Wally Avatar asked Nov 27 '22 08:11

Wally


2 Answers

When you call stat you're querying the filesystem and will be limited by its performance. For large numbers of files this will be slow; it's not really a Perl issue.

like image 122
Michael Carman Avatar answered Dec 07 '22 22:12

Michael Carman


Before you go off optimizing stat, use Devel::NYTProf to see where the real slow-down is.

Also, investigate the details of how you've mounted the filesystem. Is everything local, or have you mounted something over NFS or something similar? There are many things that can be the problem, as other answers have pointed out. Don't spend too much time focussing on any potential problem until you know it's the problem.

Good luck,

like image 31
brian d foy Avatar answered Dec 08 '22 00:12

brian d foy