in reply to Wondering about File::Find

Quick answers

1. A disk access is about 1000 times slower than memory access and thus the hash is much faster, unless the hash is too big to fit the main memory.

2. On unix, and most likely on Windows too, disk access gets cached (due to the above reason) and thus the chdir won't make much difference since find() needs to access the directory once and thus it is in the cache.



Using your hash will most likely speed things up, Note that the hash can contain only the roots in @INC and thus is very short. For this, just sort @INC and thus you will have the prefixes before the rest.

Replies are listed 'Best First'.
(tye)Re: Wondering about File::Find
by tye (Sage) on Dec 29, 2000 at 03:03 UTC

    The advantage of chdir(), at least on some systems, is that the whole path doesn't need to be traversed for each directory and file access. If you don't chdir(), then you are doing things like stat("sub/dir/tiny/file") which, even if the cache works very effectively, has to find "sub", then find "dir", then find "tiny", then find "file".

    If you chdir(), then your process keeps a handle into that directory so that stat("file") doesn't have to even look in the cache for "sub", "dir", and "tiny". I'd be interested to see benchmarks on what practical effect this can have on the whole process.

            - tye (but my friends call me "Tye")