Einmal der Unterschied zwischen MinGW 32-bit und MS Visual Studio 32-bit (Faktor 2), aber auch zwischen 32-bit und 64-bit Version (Faktor 3 bis 4), siehe Tabelle.
Der Test ist auf einen intel i7 6700HQ (4 cores) gelaufen.
Sind diese Ergebnisse repräsentativ? Sind die Unterschiede immer so groß?
Wenn jemand den MinGW 64 bit Compiler hätte, wäre ich am Vergleich MinGW32 mit MinGW64 auf einem 4 Core-Prozessor interessiert.
Die Dateien habe ich hier angehängt, sie sind ohne Änderungen Kompilierbar.
Compiler............Debug(single/multithread)....Release(single/multithread)
------------------------------------------------------------------------------------------------
MinGW 32-bit............ 5891 / 4594 ms .................. 5141 / 4047 ms
MS VS2015 32-bit........ 2891 / 3157 ms .................. 2406 / 2847 ms
MS VS2015 64-bit........ 2407 / 2422 ms ................... 688 / 969 ms
Ich liste die Pro Datei hier, weil sich diese nicht anhängen läßt( Fehler - Ungültige Dateierweiterung: test_qtconcurrent.pro)
Code: Alles auswählen
QT += core
QT += concurrent
QT -= gui
CONFIG += c++11
CONFIG += console
CONFIG -= app_bundle
TARGET = test_qtconcurrent
TEMPLATE = app
SOURCES += main.cpp
Code: Alles auswählen
#include <QCoreApplication>
#include <QtConcurrent>
#include <QFuture>
#include <QTime>
void myFunction(QString name)
{
for( int i = 0; i <= 5; ++i )
{
quint64 s = 0;
for( quint64 j = 0; j < (1000*1000*10); ++j )
s += atan(double(j)); // do something time consuming
qDebug() << name << " s:" << s;
}
}
int main( int argc, char *argv[] )
{
QCoreApplication app(argc, argv);
QTime t;
t.start();
myFunction("A");
qDebug("Time elapsed: %d ms", t.elapsed());
t.start();
QFuture<void> t1 = QtConcurrent::run(myFunction, QString("A"));
QFuture<void> t2 = QtConcurrent::run(myFunction, QString("B"));
QFuture<void> t3 = QtConcurrent::run(myFunction, QString("C"));
QFuture<void> t4 = QtConcurrent::run(myFunction, QString("D"));
t1.waitForFinished();
t2.waitForFinished();
t3.waitForFinished();
t4.waitForFinished();
qDebug("Time elapsed: %d ms", t.elapsed());
return app.exec();
}