
 Originally Posted by 
jthomps
					
				 
				QDir::entryInfoList will create all of the QFileInfo objects in one pass of the directory. If you are getting file names into a QStringList and then creating a QFileInfo for each file, then you are accessing the directory multiple times.
Is that what you are referring to? If so, makes sense to me it's way slower,
			
		 
	 
 This code:
	
	#include <QtCore>
 
int main(int argc, char **argv) {
  qDebug() << "File count:" << list.size();    
  for(int i=0;i<list.size();++i) {      
  }
  return 0;
}
        #include <QtCore>
int main(int argc, char **argv) {
  QDir dir(argv[1]);
  QStringList list = dir.entryList(QDir::NoDotAndDotDot|QDir::Files);                
  qDebug() << "File count:" << list.size();    
  for(int i=0;i<list.size();++i) {      
    const QFileInfo finfo = QFileInfo(list.at(i));
    QDateTime mtime = finfo.lastModified();
  }
  return 0;
}
To copy to clipboard, switch view to plain text mode 
  
takes this much (different computer, don't compare with previous results):
$ time ./dirtest dir
File count: 15000
real    0m0.068s
user    0m0.055s
sys     0m0.012s
I don't see any significant differences.
				
			
Bookmarks