#include <QApplication>
#include <QWidget>
#include <QPainter>
#include <QElapsedTimer>
{
public:
Widget();
protected:
private:
QElapsedTimer elapsedTimer;
int timerId;
int elapsedTime1, elapsedTime2;
bool isFinished1, isFinished2, isFinished3;
int i, x1, x2, y1, y2;
};
Widget::Widget()
{
setAutoFillBackground(true);
setPalette(Qt::white);
timerId = startTimer(1);
elapsedTimer.start();
i=0; x1=0; x2=0;
isFinished1 = isFinished2 = isFinished3 = false;
}
{
update();
}
{
if (i > 0 && i < 800)
{
// 'Test1' runs about 9 times faster than 'Test2' on Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0
y1 = 10;
painter.
setFont(QFont("Arial",
14));
painter.drawText(x1, y1 += 30, "Test 1");
painter.drawText(x1, y1 += 30, "row 01");
painter.drawText(x1, y1 += 30, "row 02");
painter.drawText(x1, y1 += 30, "row 03");
painter.drawText(x1, y1 += 30, "row 04");
painter.drawText(x1, y1 += 30, "row 05");
painter.drawText(x1, y1 += 30, "row 06");
painter.drawText(x1, y1 += 30, "row 07");
painter.drawText(x1, y1 += 30, "row 08");
painter.drawText(x1, y1 += 30, "row 09");
painter.drawText(x1, y1 += 30, "row 10");
painter.drawText(x1, y1 += 30, "row 11");
painter.drawText(x1, y1 += 30, "row 12");
x1++;
elapsedTime1 = elapsedTimer.elapsed();
}
else if (i > 800 && i < 1600)
{
// 'Test2' takes about 9 times longer than 'Test1' on Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0
isFinished1 = true;
y2 = 300;
painter.
setFont(QFont("Arial",
14));
painter.drawText(x2, y2 += 30, "Test 2");
painter.
setFont(QFont("Caladea",
14));
painter.drawText(x2, y2 += 30, "row 01");
painter.
setFont(QFont("Tomaha",
14));
painter.drawText(x2, y2 += 30, "row 02");
painter.
setFont(QFont("Consolas",
14));
painter.drawText(x2, y2 += 30, "row 03");
painter.
setFont(QFont("Calibri",
14));
painter.drawText(x2, y2 += 30, "row 04");
painter.
setFont(QFont("Impact",
14));
painter.drawText(x2, y2 += 30, "row 05");
painter.
setFont(QFont("Courier New",
14));
painter.drawText(x2, y2 += 30, "row 06");
painter.
setFont(QFont("Gorgia",
14));
painter.drawText(x2, y2 += 30, "row 07");
painter.
setFont(QFont("Verdana",
14));
painter.drawText(x2, y2 += 30, "row 08");
painter.
setFont(QFont("Times New Roman",
14));
painter.drawText(x2, y2 += 30, "row 09");
painter.
setFont(QFont("Microsoft Sans Serif",
14));
painter.drawText(x2, y2 += 30, "row 10");
painter.
setFont(QFont("Segoe UI",
14));
painter.drawText(x2, y2 += 30, "row 11");
painter.
setFont(QFont("Trebuchet MS",
14));
painter.drawText(x2, y2 += 30, "row 12");
x2++;
elapsedTime2 = elapsedTimer.elapsed();
}
else if (i > 1600)
{
isFinished2 = true;
}
i++;
if (isFinished1)
{
painter.
drawText(QPoint(200,
150),
"'Test1' elapsed time in seconds: " + QString::number(elapsedTime1
/1000.0));
}
if (isFinished2)
{
painter.
drawText(QPoint(200,
430),
"'Test2' elapsed time in seconds: " + QString::number((elapsedTime2
-elapsedTime1
)/1000.0));
isFinished3 = true;
}
if (isFinished3)
{
painter.
setFont(QFont("Arial",
11));
painter.
drawText(QPoint(200,
620),
"On Windows Desktop with Qt 5.4.2, Qt 5.5.0 and Qt 5.5.1 Test1 and Test2 are both equally fast.");
painter.
drawText(QPoint(200,
650),
"On Windows Desktop with Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0 Test2 is approx 9 times slower than Test1 !");
painter.
drawText(QPoint(200,
680),
"No matter if compiled with MinGW 32bit or MSVC 32 or 64bit");
killTimer(timerId);
}
}
int main(int argc, char *argv[])
{
Widget widget;
widget.showMaximized();
return app.exec();
}
#include <QApplication>
#include <QWidget>
#include <QPainter>
#include <QElapsedTimer>
class Widget : public QWidget
{
public:
Widget();
protected:
void timerEvent(QTimerEvent*);
void paintEvent(QPaintEvent*);
private:
QElapsedTimer elapsedTimer;
int timerId;
int elapsedTime1, elapsedTime2;
bool isFinished1, isFinished2, isFinished3;
int i, x1, x2, y1, y2;
};
Widget::Widget()
{
setAutoFillBackground(true);
setPalette(Qt::white);
timerId = startTimer(1);
elapsedTimer.start();
i=0; x1=0; x2=0;
isFinished1 = isFinished2 = isFinished3 = false;
}
void Widget::timerEvent(QTimerEvent*)
{
update();
}
void Widget::paintEvent(QPaintEvent*)
{
QPainter painter(this);
if (i > 0 && i < 800)
{
// 'Test1' runs about 9 times faster than 'Test2' on Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0
y1 = 10;
painter.setFont(QFont("Arial", 14));
painter.drawText(x1, y1 += 30, "Test 1");
painter.drawText(x1, y1 += 30, "row 01");
painter.drawText(x1, y1 += 30, "row 02");
painter.drawText(x1, y1 += 30, "row 03");
painter.drawText(x1, y1 += 30, "row 04");
painter.drawText(x1, y1 += 30, "row 05");
painter.drawText(x1, y1 += 30, "row 06");
painter.drawText(x1, y1 += 30, "row 07");
painter.drawText(x1, y1 += 30, "row 08");
painter.drawText(x1, y1 += 30, "row 09");
painter.drawText(x1, y1 += 30, "row 10");
painter.drawText(x1, y1 += 30, "row 11");
painter.drawText(x1, y1 += 30, "row 12");
x1++;
elapsedTime1 = elapsedTimer.elapsed();
}
else if (i > 800 && i < 1600)
{
// 'Test2' takes about 9 times longer than 'Test1' on Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0
isFinished1 = true;
y2 = 300;
painter.setFont(QFont("Arial", 14));
painter.drawText(x2, y2 += 30, "Test 2");
painter.setFont(QFont("Caladea", 14));
painter.drawText(x2, y2 += 30, "row 01");
painter.setFont(QFont("Tomaha", 14));
painter.drawText(x2, y2 += 30, "row 02");
painter.setFont(QFont("Consolas", 14));
painter.drawText(x2, y2 += 30, "row 03");
painter.setFont(QFont("Calibri", 14));
painter.drawText(x2, y2 += 30, "row 04");
painter.setFont(QFont("Impact", 14));
painter.drawText(x2, y2 += 30, "row 05");
painter.setFont(QFont("Courier New", 14));
painter.drawText(x2, y2 += 30, "row 06");
painter.setFont(QFont("Gorgia", 14));
painter.drawText(x2, y2 += 30, "row 07");
painter.setFont(QFont("Verdana", 14));
painter.drawText(x2, y2 += 30, "row 08");
painter.setFont(QFont("Times New Roman", 14));
painter.drawText(x2, y2 += 30, "row 09");
painter.setFont(QFont("Microsoft Sans Serif", 14));
painter.drawText(x2, y2 += 30, "row 10");
painter.setFont(QFont("Segoe UI", 14));
painter.drawText(x2, y2 += 30, "row 11");
painter.setFont(QFont("Trebuchet MS", 14));
painter.drawText(x2, y2 += 30, "row 12");
x2++;
elapsedTime2 = elapsedTimer.elapsed();
}
else if (i > 1600)
{
isFinished2 = true;
}
i++;
if (isFinished1)
{
painter.setFont(QFont("Arial", 12, QFont::Bold));
painter.drawText(QPoint(200, 150), "'Test1' elapsed time in seconds: " + QString::number(elapsedTime1/1000.0));
}
if (isFinished2)
{
painter.drawText(QPoint(200, 430), "'Test2' elapsed time in seconds: " + QString::number((elapsedTime2-elapsedTime1)/1000.0));
isFinished3 = true;
}
if (isFinished3)
{
painter.setFont(QFont("Arial", 11));
painter.drawText(QPoint(200, 620), "On Windows Desktop with Qt 5.4.2, Qt 5.5.0 and Qt 5.5.1 Test1 and Test2 are both equally fast.");
painter.drawText(QPoint(200, 650), "On Windows Desktop with Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0 Test2 is approx 9 times slower than Test1 !");
painter.drawText(QPoint(200, 680), "No matter if compiled with MinGW 32bit or MSVC 32 or 64bit");
killTimer(timerId);
}
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Widget widget;
widget.showMaximized();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Did you know how to report a bug report to the Qt developer team? Never did that before. Can you help me with this?
Bookmarks