Some time ago, Darryl Okahata wrote...
|+
| I don't know about NT, but stat() is VERY expensive under Win95.
| If I recall correctly, a call to stat() takes on the order of
| milliseconds on a non-MMX P166 (and I think over 10ms), under Win95
| OSR2. Why, I don't know (this is real/elapsed, and not CPU, time). By
| bypassing stat(), and using the native Win32 system calls, my dired-in-C
| changes were able to get a significant performance improvement.
|-
Ok, I wrote a simple statometer. On my system (P133 64MB NT 4.0 SP3) it
averages to around 800 us per stat call.
398 stats in 325 ms, 818 us per call
398 stats in 325 ms, 818 us per call
398 stats in 328 ms, 824 us per call
398 stats in 328 ms, 824 us per call
398 stats in 325 ms, 819 us per call
Generally this means that XEmacs spends almost 2 seconds in stats
on statup, if it counts to 2,000 stats.
Here's a source, perhaps useless outside of win32 world. Anybody's out
to port this on UNIX?
#include <windows.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
void main ()
{
LARGE_INTEGER start, end, res;
LONGLONG time = 0;
int ncalls = 0;
WIN32_FIND_DATA wfd;
struct stat statbuf;
HANDLE hf = FindFirstFile ("*", &wfd);
if (hf)
do {
QueryPerformanceCounter (&start);
stat (wfd.cFileName, &statbuf);
QueryPerformanceCounter (&end);
time += end.QuadPart - start.QuadPart;
++ncalls;
} while (FindNextFile (hf, &wfd));
QueryPerformanceFrequency (&res);
printf ("%d stats in %ld ms, %ld us per call\n",
ncalls,
(long)(time * 1000 / res.QuadPart),
(long)(time * 1000000 / ncalls / res.QuadPart));
}