Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - Anything faster than stat() ?

 
Thread Tools Search this Thread
Old 07-07-2003, 05:55 AM   #1
Default 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




Ken Tucker
  Reply With Quote
Old 07-08-2003, 07:29 AM   #2
Steve Grazzini
 
Posts: n/a
Default Re: Anything faster than stat() ?

Ken Tucker <> 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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump