Create QPrinter is very slow under Qt5
-
Hi everyone,
Why under Qt 5.5 the creation of QPrint object is very slow:This code
[code]
QElapsedTimer timer;
timer.start();
QPrinter printer;
qDebug() << "The operation took" << timer.elapsed() << "milliseconds";
[/code]Measured with QElapsedTimer, Output:
Qt4.8.7
The operation took **740 milliseconds **Qt5.5
The operation took 2391 millisecondsAmazing?!
-
Hi,
IMO your code is not correct. This should be the right way to measure the time
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QElapsedTimer timer; timer.start(); QPrinter printer; qint64 elapsed = timer.nsecsElapsed(); qDebug() << "Elapsed:" << elapsed << "ns"; return 0; }
because in your code
elapsed()
is called only after some output operations.Anyway, in my environment (Qt 5.5.1 on OS X) the output is always between 1.2 and 1.6 ms.
In which platform are you running that code? -
@mcosta I use the typical case in the doc
http://doc.qt.io/qt-4.8/qelapsedtimer.htmlMy env: MSWindows7 64bit
-
Hi,
changing my code according the Qt doc doesn't change the result. IMO that code is not correct if you want to make a real measure
-
With your code:
Qt4.8.7
MSWindows 7 64bit (bin 32bit): The operation took 683 835637 nsQt5.5
MSWindows 7 64bit (bin 32bit): The operation took 2423 792254 ns
Ubuntu 14.04.3 LTS 64bits: The operation took 17 481614 nsBig difference with Linux system.
4/6