From: Eli Zaretskii Newsgroups: comp.os.msdos.djgpp Subject: Re: Reading directories, readdir/stat too slow Date: Thu, 30 Sep 1999 16:17:21 +0200 Organization: NetVision Israel Lines: 31 Message-ID: References: <37f307e1 DOT 967161774 AT news DOT xmission DOT com> NNTP-Posting-Host: is.elta.co.il Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: news.netvision.net.il 938700968 25688 199.203.121.2 (30 Sep 1999 14:16:08 GMT) X-Complaints-To: abuse AT netvision DOT net DOT il NNTP-Posting-Date: 30 Sep 1999 14:16:08 GMT X-Sender: eliz AT is In-Reply-To: <37f307e1.967161774@news.xmission.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Thu, 30 Sep 1999, Scott Brown wrote: > Unfortunately, I find that opendir/readdir, when combined with a stat > call (to get file mode/size/etc) is a *lot* slower than findfirst, > taking on the order of 70-100 times longer to perform the same work. > When running against tens of thousands of files in hundreds of > directories, it is a significant problem. stat is expensive (it isn't easy to get all that info on DOS; you won't believe how closely DOS guards some of its dirty secrets ;-). But 100 times slower seems to be too much; I suspect your system is not set up in an optimal way. See section 3.9 of the FAQ; in particular, make sure you have a disk cache installed. A 10-fold slow-down when using stat is something I would expect, but not 100-fold. > Is there any way to speed things up? Read the docs ;-). No, seriously: the documentation of _djstat_flags in libc.info describes several flags that can be set to disable computing some expensive members of struct stat for which you don't have any use. For the fastest operation, you should disable all features but those which your application needs. Doing so is known to speed up stat tremendously. If you cannot figure some details out, please post specific questions. If setting some of the _STAT_XXX bits still doesn't speed up the program, post here the details about what your application does and what bits did you try to set, and somebody will help you more.