This is Windows 7, 64 bit, Professional using
Consider a very simple loop
for (i = 0; i < names->size(); i++)
{
std::string Name = names->at(i);
HANDLE fileHandle = CreateFile(Name.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (fileHandle == INVALID_HANDLE_VALUE)
{
throw "Failed";
}
CloseHandle(fileHandle);
}
If I run this in a directory with 863 files, it takes just over 22 seconds or 25 milliseconds / file. Next time, 169 milliseconds or 0.19 milliseconds / file. If I just use find_file time in the new directory, it is very fast, about 0.2 ms / file. Although I used CreateFile here, other methods give the same results.
Of course, the answer is file caching: windows should cache file opening information. Moreover, it should be access to the disk, as if the directory was on the SSD, the first and second open approximately the same.
9 , - , WINDOWS, 25 , / . , . , 25 , , 33 , 30 , .
, **.