#include <QCoreApplication>#include<QFile>#include<QDir>#include<QTime>#include<QDebug>const QString folderPath = "D:\\ForSend\\FolderSend";const QChar subdirSeparator = '\\';int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); QDir dir(folderPath); QStringList dirFiles = dir.entryList(QDir::Files|QDir::NoDotAndDotDot|QDir::Hidden); for (QStringList::const_iterator it = dirFiles.begin(); it != dirFiles.end(); ++it) { QString fullPath1 = folderPath + subdirSeparator + *it; QFile f(fullPath1); QTime t1 = QTime::currentTime(); f.open(QIODevice::ReadOnly); QTime t2 = QTime::currentTime(); f.close(); qDebug() << t1 << endl << t2 << endl << *it; } return a.exec();}
#include <QCoreApplication>#include<QFile>#include<QDir>#include<QTime>#include<QElapsedTimer>#include<QDebug>const QString folderPath = "D:\\ForSend\\FolderSend3";const QChar subdirSeparator = '\\';int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); QDir dir(folderPath); QStringList dirFiles = dir.entryList(QDir::Files|QDir::NoDotAndDotDot|QDir::Hidden); int counter = 0; QElapsedTimer timer; for (QStringList::const_iterator it = dirFiles.begin(); it != dirFiles.end(); ++it) { QString fullPath1 = folderPath + subdirSeparator + *it; QFile f(fullPath1); QTime t1 = QTime::currentTime(); f.open(QIODevice::ReadOnly); QTime t2 = QTime::currentTime(); //f.close(); qDebug() << t1 << endl << t2 << endl << *it << counter; counter++; if(counter == 1000){ counter = 0; timer.start(); while (timer.elapsed() < 5000) { continue; } } } return a.exec();}