Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Get useful info about a directory tree

by merlyn (Sage)
on Jan 24, 2011 at 22:40 UTC ( [id://884017]=note: print w/replies, xml ) Need Help??


in reply to Get useful info about a directory tree

Meanwhile a simple, recursive "opendir/readdir" process works reasonably and consistently well in all cases (and is also a lot faster than File::Find),
Since that's precisely what File::Find is doing, I'm curious as to how you were using it. Do you have some code from your failed File::Find experiments that we can benchmark?

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

  • Comment on Re: Get useful info about a directory tree

Replies are listed 'Best First'.
Re^2: Get useful info about a directory tree
by graff (Chancellor) on Jan 25, 2011 at 09:25 UTC
    Thanks for asking... Yes, I'd be grateful if someone could check my work on this: On a "mature" darwin laptop (2.16 GHz macbook, osx 10.6.6, perl 5.10.0, File::Find 1.12), with a tree containing 800 or so subdirectories at various depths, I get output like this (29485 is the count of data files):
    Benchmark: timing 30 iterations of Shell find pipe, _ Opendir recursion, __ File::Find module... 29485 Shell find pipe: 7 wallclock secs ( 0.56 usr 0.40 sys + 1.03 cusr 3.87 csys = 5.8 +6 CPU) @ 5.12/s (n=30) 29485 _ Opendir recursion: 12 wallclock secs ( 3.79 usr + 5.63 sys = 9.42 CPU) @ 3.18/s (n=30 +) 29485 __ File::Find module: 20 wallclock secs ( 8.17 usr + 7.32 sys = 15.49 CPU) @ 1.94/s (n=30 +)
    If you remove the parts about writing file names to temp files, the times all go down, but the relative proportions stay about the same. (I was writing temp files just to be sure I got the same output with each method. It took a few tries to handle the symbolic links consistently.)

    I presume File::Find has a noticeable amount of overhead relative to a minimal recursion of opendir/readdir, but I haven't looked at the source code to check on that.

      This script is really nice and usefull. Is it possible to include the owner of the files/directory?
        It so happens that during the year that passed between the previous update and your question, I added a '-u' option to handle just that: include user names (or user id's) of directory owners (along with a couple other new options, including a treatment for hard-links that happen to be contained within the directory tree(s) being scanned). The OP has been updated with my current version.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://884017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-16 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found