summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/benchmarks.pro5
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/main.cpp4
-rw-r--r--tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro4
-rw-r--r--tests/benchmarks/corelib/io/qtextstream/qtextstream.pro2
-rw-r--r--tests/benchmarks/corelib/kernel/kernel.pro3
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp88
-rw-r--r--tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro4
-rw-r--r--tests/benchmarks/corelib/tools/qdatetime/main.cpp5
-rw-r--r--tests/benchmarks/corelib/tools/qmap/qmap.pro2
-rw-r--r--tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp14
-rw-r--r--tests/benchmarks/testlib/testlib.pro3
-rw-r--r--tests/benchmarks/testlib/tostring/tostring.pro4
-rw-r--r--tests/benchmarks/testlib/tostring/tst_tostring.cpp103
13 files changed, 208 insertions, 33 deletions
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index 9e288f7aa2..a98b9a62c6 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -3,10 +3,11 @@ SUBDIRS = \
corelib \
sql \
-# removed-by-refactor qtHaveModule(opengl): SUBDIRS += opengl
qtHaveModule(dbus): SUBDIRS += dbus
-qtHaveModule(network): SUBDIRS += network
qtHaveModule(gui): SUBDIRS += gui
+qtHaveModule(network): SUBDIRS += network
+# removed-by-refactor qtHaveModule(opengl): SUBDIRS += opengl
+qtHaveModule(testlib): SUBDIRS += testlib
qtHaveModule(widgets): SUBDIRS += widgets
check-trusted.CONFIG += recursive
diff --git a/tests/benchmarks/corelib/io/qfileinfo/main.cpp b/tests/benchmarks/corelib/io/qfileinfo/main.cpp
index 104c01d118..6cc96777a1 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/main.cpp
+++ b/tests/benchmarks/corelib/io/qfileinfo/main.cpp
@@ -81,7 +81,7 @@ void qfileinfo::symLinkTargetPerformanceLNK()
QString linkTarget;
QBENCHMARK {
for(int i=0; i<100; i++)
- linkTarget = info.readLink();
+ linkTarget = info.symLinkTarget();
}
QVERIFY(QFile::remove("link.lnk"));
}
@@ -104,7 +104,7 @@ void qfileinfo::symLinkTargetPerformanceMounpoint()
QString linkTarget;
QBENCHMARK {
for(int i=0; i<100; i++)
- linkTarget = info.readLink();
+ linkTarget = info.symLinkTarget();
}
QVERIFY(QDir().rmdir(mountpoint));
}
diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro
index cb8dfdcdcb..a0230e1cb8 100644
--- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro
+++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro
@@ -1,5 +1,5 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
winrt: QMAKE_LFLAGS += /ENTRY:mainCRTStartup
DESTDIR = ./
diff --git a/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro b/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro
index 758930c139..e8170319f2 100644
--- a/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro
+++ b/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro
@@ -1,5 +1,5 @@
TEMPLATE = app
-TARGET = tst_bench_qtemporaryfile
+TARGET = tst_bench_qtextstream
QT = core testlib
diff --git a/tests/benchmarks/corelib/kernel/kernel.pro b/tests/benchmarks/corelib/kernel/kernel.pro
index 02eeeaa254..92f7174419 100644
--- a/tests/benchmarks/corelib/kernel/kernel.pro
+++ b/tests/benchmarks/corelib/kernel/kernel.pro
@@ -5,7 +5,8 @@ SUBDIRS = \
qmetatype \
qobject \
qvariant \
- qcoreapplication
+ qcoreapplication \
+ qtimer_vs_qmetaobject
!qtHaveModule(widgets): SUBDIRS -= \
qmetaobject \
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
index 66a29780f0..6af5b8d586 100644
--- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
@@ -28,6 +28,7 @@
#include <QtCore>
#include <QtTest/QtTest>
+#include <QThread>
#define INVOKE_COUNT 10000
@@ -35,8 +36,10 @@ class qtimer_vs_qmetaobject : public QObject
{
Q_OBJECT
private slots:
- void testZeroTimerSingleShot();
- void testQueuedInvokeMethod();
+ void bench();
+ void bench_data();
+ void benchBackgroundThread();
+ void benchBackgroundThread_data() { bench_data(); }
};
class InvokeCounter : public QObject {
@@ -47,36 +50,89 @@ public slots:
void invokeSlot() {
count++;
if (count == INVOKE_COUNT)
- QTestEventLoop::instance().exitLoop();
+ emit allInvoked();
}
+signals:
+ void allInvoked();
protected:
int count;
};
-void qtimer_vs_qmetaobject::testZeroTimerSingleShot()
+void qtimer_vs_qmetaobject::bench()
{
+ QFETCH(int, type);
+
+ std::function<void(InvokeCounter*)> invoke;
+ if (type == 0) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, invokeCounter, SLOT(invokeSlot()));
+ };
+ } else if (type == 1) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, invokeCounter, &InvokeCounter::invokeSlot);
+ };
+ } else if (type == 2) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, invokeCounter, [invokeCounter]() {
+ invokeCounter->invokeSlot();
+ });
+ };
+ } else if (type == 3) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, [invokeCounter]() {
+ invokeCounter->invokeSlot();
+ });
+ };
+ } else if (type == 4) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QMetaObject::invokeMethod(invokeCounter, "invokeSlot", Qt::QueuedConnection);
+ };
+ } else if (type == 5) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QMetaObject::invokeMethod(invokeCounter, &InvokeCounter::invokeSlot, Qt::QueuedConnection);
+ };
+ } else if (type == 6) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QMetaObject::invokeMethod(invokeCounter, [invokeCounter]() {
+ invokeCounter->invokeSlot();
+ }, Qt::QueuedConnection);
+ };
+ } else {
+ QFAIL("unhandled data tag");
+ }
+
QBENCHMARK {
InvokeCounter invokeCounter;
+ QSignalSpy spy(&invokeCounter, &InvokeCounter::allInvoked);
for(int i = 0; i < INVOKE_COUNT; ++i) {
- QTimer::singleShot(0, &invokeCounter, SLOT(invokeSlot()));
+ invoke(&invokeCounter);
}
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(spy.wait(10000));
}
}
-void qtimer_vs_qmetaobject::testQueuedInvokeMethod()
+void qtimer_vs_qmetaobject::bench_data()
{
- QBENCHMARK {
- InvokeCounter invokeCounter;
- for(int i = 0; i < INVOKE_COUNT; ++i) {
- QMetaObject::invokeMethod(&invokeCounter, "invokeSlot", Qt::QueuedConnection);
- }
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- }
+ QTest::addColumn<int>("type");
+ QTest::addRow("singleShot_slot") << 0;
+ QTest::addRow("singleShot_pmf") << 1;
+ QTest::addRow("singleShot_functor") << 2;
+ QTest::addRow("singleShot_functor_noctx") << 3;
+ QTest::addRow("invokeMethod_string") << 4;
+ QTest::addRow("invokeMethod_pmf") << 5;
+ QTest::addRow("invokeMethod_functor") << 6;
}
+void qtimer_vs_qmetaobject::benchBackgroundThread()
+{
+#if !QT_CONFIG(cxx11_future)
+ QSKIP("This test requires QThread::create");
+#else
+ QScopedPointer<QThread> thread(QThread::create([this]() { bench(); }));
+ thread->start();
+ QVERIFY(thread->wait());
+#endif
+}
QTEST_MAIN(qtimer_vs_qmetaobject)
diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro b/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro
index 9c55de8b47..cf9d640f7e 100644
--- a/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro
+++ b/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro
@@ -1,5 +1,5 @@
TARGET = tst_bench_qcryptographichash
-CONFIG -= debug app_bundle
-CONFIG += release console
+CONFIG -= debug
+CONFIG += release cmdline
QT = core testlib
SOURCES += main.cpp
diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp
index 2c1e3d97ae..b693400376 100644
--- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp
+++ b/tests/benchmarks/corelib/tools/qdatetime/main.cpp
@@ -35,10 +35,7 @@ class tst_QDateTime : public QObject
{
Q_OBJECT
- enum
-#if defined(Q_COMPILER_CLASS_ENUM) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700)
- : qint64
-#endif
+ enum : qint64
{
SECS_PER_DAY = 86400,
MSECS_PER_DAY = 86400000,
diff --git a/tests/benchmarks/corelib/tools/qmap/qmap.pro b/tests/benchmarks/corelib/tools/qmap/qmap.pro
index 6a0c8d62bd..6c9bf5e8d6 100644
--- a/tests/benchmarks/corelib/tools/qmap/qmap.pro
+++ b/tests/benchmarks/corelib/tools/qmap/qmap.pro
@@ -1,4 +1,4 @@
-TARGET = tst_qmap
+TARGET = tst_bench_qmap
QT = core testlib
INCLUDEPATH += .
SOURCES += main.cpp
diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
index e0f69bee11..570c7b59fa 100644
--- a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
+++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
@@ -200,6 +200,8 @@ void tst_QImageConversion::convertRgb32_data()
QTest::newRow("argb32 -> argb8565pm") << argb32 << QImage::Format_ARGB8565_Premultiplied;
QTest::newRow("argb32 -> argb4444pm") << argb32 << QImage::Format_ARGB4444_Premultiplied;
QTest::newRow("argb32 -> argb6666pm") << argb32 << QImage::Format_ARGB6666_Premultiplied;
+ QTest::newRow("argb32 -> rgba64") << argb32 << QImage::Format_RGBA64;
+ QTest::newRow("argb32 -> rgba64pm") << argb32 << QImage::Format_RGBA64_Premultiplied;
QTest::newRow("argb32pm -> rgb16") << argb32pm << QImage::Format_RGB16;
QTest::newRow("argb32pm -> rgb32") << argb32pm << QImage::Format_RGB32;
@@ -239,6 +241,7 @@ void tst_QImageConversion::convertGeneric_data()
QImage a2rgb30 = argb32.convertToFormat(QImage::Format_A2RGB30_Premultiplied);
QImage rgb666 = rgb32.convertToFormat(QImage::Format_RGB666);
QImage argb4444 = argb32.convertToFormat(QImage::Format_ARGB4444_Premultiplied);
+ QImage rgba64pm = argb32.convertToFormat(QImage::Format_RGBA64_Premultiplied);
QTest::newRow("indexed8 -> rgb32") << i8 << QImage::Format_RGB32;
QTest::newRow("indexed8 -> argb32") << i8 << QImage::Format_ARGB32;
@@ -289,6 +292,13 @@ void tst_QImageConversion::convertGeneric_data()
QTest::newRow("argb4444pm -> rgba8888pm") << argb4444 << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("argb4444pm -> rgb30") << argb4444 << QImage::Format_RGB30;
QTest::newRow("argb4444pm -> a2bgr30") << argb4444 << QImage::Format_A2BGR30_Premultiplied;
+
+ QTest::newRow("rgba64pm -> argb32") << rgba64pm << QImage::Format_ARGB32;
+ QTest::newRow("rgba64pm -> rgbx8888") << rgba64pm << QImage::Format_RGBX8888;
+ QTest::newRow("rgba64pm -> rgba8888pm") << rgba64pm << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("rgba64pm -> rgb30") << rgba64pm << QImage::Format_RGB30;
+ QTest::newRow("rgba64pm -> a2bgr30") << rgba64pm << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("rgba64pm -> rgba64") << rgba64pm << QImage::Format_RGBA64;
}
void tst_QImageConversion::convertGeneric()
@@ -347,10 +357,10 @@ void tst_QImageConversion::convertGenericInplace()
QFETCH(QImage::Format, outputFormat);
QImage::Format inputFormat = inputImage.format();
- QImage tmpImage = qMove(inputImage);
+ QImage tmpImage = std::move(inputImage);
QBENCHMARK {
- tmpImage = (qMove(tmpImage).convertToFormat(outputFormat)).convertToFormat(inputFormat);
+ tmpImage = (std::move(tmpImage).convertToFormat(outputFormat)).convertToFormat(inputFormat);
}
}
diff --git a/tests/benchmarks/testlib/testlib.pro b/tests/benchmarks/testlib/testlib.pro
new file mode 100644
index 0000000000..c325f3de9a
--- /dev/null
+++ b/tests/benchmarks/testlib/testlib.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ tostring \
diff --git a/tests/benchmarks/testlib/tostring/tostring.pro b/tests/benchmarks/testlib/tostring/tostring.pro
new file mode 100644
index 0000000000..a5aebe1c81
--- /dev/null
+++ b/tests/benchmarks/testlib/tostring/tostring.pro
@@ -0,0 +1,4 @@
+TARGET = tst_bench_tostring
+QT = core testlib
+
+SOURCES += tst_tostring.cpp
diff --git a/tests/benchmarks/testlib/tostring/tst_tostring.cpp b/tests/benchmarks/testlib/tostring/tst_tostring.cpp
new file mode 100644
index 0000000000..1731929f98
--- /dev/null
+++ b/tests/benchmarks/testlib/tostring/tst_tostring.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qmath.h> // pi, e
+
+// Tests for QTest::toString
+class tst_toString : public QObject
+{
+ Q_OBJECT
+
+ template <typename T> void numeric_data();
+ template <typename T> void numeric();
+
+private slots:
+ void floatTst_data() { numeric_data<float>(); }
+ void floatTst() { numeric<float>(); }
+ void doubleTst_data() { numeric_data<double>(); }
+ void doubleTst() { numeric<double>(); }
+ void intTst_data() { numeric_data<int>(); }
+ void intTst() { numeric<int>(); }
+ void unsignedTst_data() { numeric_data<unsigned>(); }
+ void unsignedTst() { numeric<unsigned>(); }
+ void quint64Tst_data() { numeric_data<quint64>(); }
+ void quint64Tst() { numeric<quint64>(); }
+ void qint64Tst_data() { numeric_data<qint64>(); }
+ void qint64Tst() { numeric<qint64>(); }
+};
+
+template <typename T>
+void tst_toString::numeric_data()
+{
+ QTest::addColumn<T>("datum");
+ const bool floaty = std::is_floating_point<T>::value;
+
+ QTest::newRow("zero") << T(0);
+ QTest::newRow("one") << T(1);
+ if (floaty) {
+ QTest::newRow("pi") << T(M_PI);
+ QTest::newRow("e") << T(M_E);
+
+ // Stress canonicalisation of leading zeros on exponents:
+ QTest::newRow("milli") << T(1e-3);
+ QTest::newRow("micro") << T(1e-6);
+ QTest::newRow("mu0") << T(.4e-6 * M_PI); // Henry/metre
+ QTest::newRow("Planck") << T(662.606876e-36); // Joule.second/turn
+ }
+ QTest::newRow("2e9") << T(2000000000);
+ QTest::newRow("c.s/m") << T(299792458);
+ QTest::newRow("Avogadro") << T(6.022045e+23); // things/mol (.996 << 79, so ints overflow to max)
+
+ QTest::newRow("lowest") << std::numeric_limits<T>::lowest();
+ QTest::newRow("max") << std::numeric_limits<T>::max();
+ if (floaty) {
+ QTest::newRow("min") << std::numeric_limits<T>::min();
+
+ if (std::numeric_limits<T>::has_infinity) {
+ const T uge = std::numeric_limits<T>::infinity();
+ QTest::newRow("inf") << uge;
+ QTest::newRow("-inf") << -uge;
+ }
+ if (std::numeric_limits<T>::has_quiet_NaN)
+ QTest::newRow("nan") << std::numeric_limits<T>::quiet_NaN();
+ }
+}
+
+template <typename T>
+void tst_toString::numeric()
+{
+ QFETCH(T, datum);
+
+ QBENCHMARK {
+ QTest::toString<T>(datum);
+ }
+}
+
+QTEST_MAIN(tst_toString)
+#include "tst_tostring.moc"