I want to calculate MD5 hash of the file.
If I use fast_md5 with native lib http://twmacinta.com/myjava/fast_md5.php, then Java read file from HDD with 90 MB/s...120 MB/s and calc time is 70 seconds.
If I use QT
QCryptographicHash hash(QCryptographicHash::Md5);
QFile in("C:/file.mkv");
QFileInfo fileInfo("C:/file.mkv");
qint64 imageSize = fileInfo.size();
const int bufferSize = 1000000;
char buf[bufferSize+5];
int bytesRead;
if (in.open(QIODevice::ReadOnly)) {
while ( (bytesRead = in.read(buf, bufferSize)) > 0) {
// imageSize -= bytesRead;
// hash.addData(buf, bytesRead);
}
}
else {
qDebug() << "Failed to open device!";
}
in.close();
qDebug() << hash.result().toHex();
then my program read file from HDD with speed 20...78 MB/s and calc time is 210 seconds.
Is it possible to accelerate the processing of MD5 Calc in QT? May need to increase the buffer from 1000000 to a larger value?
The best solution is
This solution provides to me the best read speed (about 100-120 MB/s) and the best calc time - 51...75 secs.
From https://qt-project.org/forums/viewthread/41886