Description
ghc::filesystem is slower than std::filesystem on Windows when working with directories that contain many files.
I tested it in directory which contains about 16600 files.
Enumerating files via ghc::filesystem takes about 50-60 seconds on my PC (NTFS, HDD).
Enumerating files via std::filesystem used from example code takes 2.5-5 seconds (same directory).
fs::path object_path = fs::u8path(start_path);
for (auto &entry_path : fs::directory_iterator(object_path)) {
fs::file_status entry_status = fs::status(entry_path);
// some simple operations like push names to list
}
I think the problem corresponds to non-optimized iterator operators and 'status' operations.
Please look on call stack on image. Simple iterator increment operation requires call for 'status', which processed all data gathering, strings assigning, etc. So, for single pass for one file, 'status' operation called so many times with gathering a lot of not necessary information.
Maybe caching of file names, extensions, root paths, etc. instead calculation on each call, will make library faster.