Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
Qt Creator 10.0.0-beta2
-
None
Description
It looks like SubDirFileIterator is slower about 20 times comparing to QDir::entryInfoList() when done recursively in case many files / dirs are being iterated. I've set homePath to path where I have about 1.5 million files and about 200 K dirs. Modify this path accordingly when verifying the code below:
const QString homePath = QDir::homePath() + "/dev/"; qDebug() << homePath; { QElapsedTimer timer; timer.start(); int dirCount = 0; int count = 0; const QDir home(homePath); QFileInfoList workingList = home.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot); while (!workingList.isEmpty()) { const QFileInfo fi = workingList.takeLast(); if (fi.isDir()) { ++dirCount; workingList.append(QDir(fi.filePath()).entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot)); } else { ++count; if (count % 100000 == 0) qDebug() << count; } } qDebug() << "EntryInfoList: Elapsed" << timer.elapsed() << "ms, count" << count << "dir count:" << dirCount; } { QElapsedTimer timer; timer.start(); int count = 0; const FilePath home(FilePath::fromString(homePath)); SubDirFileIterator it({home}, {}, {}); auto i = it.begin(); const auto e = it.end(); while (i != e) { ++count; ++i; if (count % 100000 == 0) qDebug() << count; } qDebug() << "SubDirIterator: Elapsed" << timer.elapsed() << "ms, count" << count; }
My output:
EntryInfoList: Elapsed 9795 ms, count 1437077 dir count: 196468 SubDirIterator: Elapsed 174612 ms, count 1436843
Side note: not sure why the number of files differ in both cases.