Re: A somewhat faster alternative to is_dir and is_file?

From: Date: Thu, 09 Sep 2004 09:55:45 +0000
Subject: Re: A somewhat faster alternative to is_dir and is_file?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-196201@lists.php.net to get a copy of this message
Wouter van Vliet wrote:
Howdy, I've written some, kinda coolish, class that reads directories recursively with some simple calls. Yihaaa, .. (but I'm not the only one who has done that, I guess :P). Anyway, during the process of traversing a directory it checks to see if the "something" that was found is either a directory or a file, based on that it will do some things. Fine, works. But, now that I've got a directory with about 800 files to read I noticed that it takes the poor script almost two seconds to find the correct type of all the "somethings". In fact, I timed it on a steady 1.71. I've tried to use filetype() on the "something", but that took even longer - while looping through the directory without any checks finishes in 0.01 seconds. Now, for the question: does anybody know an alternative method on checking whether a "something" is either file or directory? Wouter (this time, I'm on a Windows XP machine running PHP5 - just tested the same thing on Linux and PHP 4.3.8 and came out on 0.63 secs, ..)
Depends on the filesystem. There are not many alternatives in WXP, but FAT should be faster.

« previous php.general (#196201) next »