So, I have th is function called lookat(). It basically puts selected
stat data of files into a hash of hashes (%dirs) as you can see.
Is there any better way to gather a bunch of files' stat data than
looping and calling lstat?
Recent profiling of my code (props to Jeff Pinyan for some awesome
optimisations) shows, of course, that the endless stating of 120,000+
files with an average of 5,000+ files in a dir can be time consuming.
BTW, using XFS is really great. Reiser is probably way better on a 1GHz,
but on my 350 XFS rox.
Vital statistics:
perl 5.7.1
Mandrake 8.0
glibc-2.2.2-4mdk
gcc version 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)
sub lookat {
my ($entry) = @_;
my $name = "lookat";
my (@files);
return if exists($dirs{$entry});
print "\t$name -> traversing $entry\n" if DEBUG & TRAVERSE;
$dirs{$entry} = {};
opendir DIR, $entry or die "can't open $entry: $!\n";
for (grep !/^\.\.?$/, readdir DIR) {
next if exists($ignore{$_});
my $file = "$entry/$_";
$file =~ s!//!/!g;
my @stats = ( '0', (lstat $file)[0,1,7,9] );
if (-r _ && -f _) {
print "\t\t$name -> F $file\n" if DEBUG & REPORT;
$dirs{$entry}{$_} = \@stats;
}
elsif (-r _ && -d _ && -x _) {
print "\t\t$name -> D $file\n" if DEBUG & REPORT;
lookat($file) unless exists($opts{norecurse});
}
}
closedir(DIR);
if ($opts{'moresync'}) {
loadix($entry);
for (keys %{ $dirs{$entry} }) {
gonkulate($entry,$_) if $dirs{$entry}{$_}[0] eq '0';
}
rend_thee($entry) if exists($meta{$entry}{nuptdate});
}
}
--
Hob Goblin
[EMAIL PROTECTED]
"Pinky, you've left the lens cap of your mind on again." - The Brain
Summary of my perl5 (revision 5.0 version 7 subversion 1) configuration:
Platform:
osname=linux, osvers=2.4.4-ac5.xfs, archname=i686-linux
uname='linux ahkbarr.dynip.com 2.4.4-ac5.xfs #1 tue may 8 13:38:10 cdt 2001 i686
unknown '
config_args='-de'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at May 10 2001 14:50:49
@INC:
/usr/local/lib/perl5/5.7.1/i686-linux
/usr/local/lib/perl5/5.7.1
/usr/local/lib/perl5/site_perl/5.7.1/i686-linux
/usr/local/lib/perl5/site_perl/5.7.1
/usr/local/lib/perl5/site_perl
.