Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl (http://www.velocityreviews.com/forums/f17-perl.html)
-   -   Anything faster than stat() ? (http://www.velocityreviews.com/forums/t24129-anything-faster-than-stat.html)

Ken Tucker 07-07-2003 04:55 AM

Anything faster than stat() ?
 
Help!

I'm recursing through 10,000 directories where some have as few as 5 files
and others have 100's. I'm then performing a few things based on the modify
date of the file. Needless to say, this script is going to run a long time
regardless of what I do. But if I remove the stat, the script runs 500%
faster (duh). That being said, I've set out to find something faster than
stat if at all possible (since stat gets much more info than I need).

I've noted that doing a file check (-f) slows down execution significantly
so I've removed it in favor of regular expressions, but I can't find another
way to get the modify date of each file other than stat and -M.

Anyone have any other ideas? I'm running this in Win32, so I'm sure that's
part of the cause, but perhaps there's a stat-like command that ONLY grabs
modify date, or perhaps there's something in a Win32 module that I haven't
found.

Here's a snippet of code in case it helps.

# open the current directory
opendir D, "$checkpath";

# loop through files in directory
while (defined($file = readdir D)) {
chomp($file);
# if there's a . in the file, it must be real (weak but works for
now)
if ($file=~ /\./) {
# get the time, in seconds, of the file since Jan 1 1970
$filetime = int((stat($file))[9]); <--- SLOW!

# do something with it...
}
}

Thanks in advance!
-Ken



Steve Grazzini 07-08-2003 06:29 AM

Re: Anything faster than stat() ?
 
Ken Tucker <ken@nospam.iit.net> wrote:
> Forget stat(). I just used regular expressions to parse through
> a DOS directory listing ... it went from 256 seconds to 16 seconds


That will be specific to Windows.

> So - word to the wise -


[ insert joke here ]

--
Steve


All times are GMT. The time now is 02:57 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.