summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro3
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp91
-rw-r--r--tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp2
-rw-r--r--tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp34
-rw-r--r--tests/benchmarks/network/socket/qudpsocket/qudpsocket.pro8
-rw-r--r--tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp80
-rw-r--r--tests/benchmarks/network/socket/socket.pro3
-rw-r--r--tests/benchmarks/sql/kernel/qsqlquery/main.cpp6
8 files changed, 181 insertions, 46 deletions
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
index 86102adecd..a1827d0276 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
@@ -1,6 +1,7 @@
TEMPLATE = app
TARGET = tst_bench_qreadwritelock
-QT = core testlib
+QT = core-private testlib
SOURCES += tst_qreadwritelock.cpp
CONFIG += c++14 # for std::shared_timed_mutex
+CONFIG += c++1z # for std::shared_mutex
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
index fcf600a059..1d47d98657 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -28,12 +28,14 @@
#include <QtCore/QtCore>
#include <QtTest/QtTest>
+#include <QtCore/private/qmemory_p.h>
#include <mutex>
#if QT_HAS_INCLUDE(<shared_mutex>)
#if __cplusplus > 201103L
#include <shared_mutex>
#endif
#endif
+#include <vector>
// Wrapers that take pointers instead of reference to have the same interface as Qt
template <typename T>
@@ -63,6 +65,8 @@ private slots:
void uncontended();
void readOnly_data();
void readOnly();
+ void writeOnly_data();
+ void writeOnly();
// void readWrite();
};
@@ -106,6 +110,14 @@ void tst_QReadWriteLock::uncontended_data()
<< FunctionPtrHolder(testUncontended<QReadWriteLock, QWriteLocker>);
QTest::newRow("std::mutex") << FunctionPtrHolder(
testUncontended<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#ifdef __cpp_lib_shared_mutex
+ QTest::newRow("std::shared_mutex, read") << FunctionPtrHolder(
+ testUncontended<std::shared_mutex,
+ LockerWrapper<std::shared_lock<std::shared_mutex>>>);
+ QTest::newRow("std::shared_mutex, write") << FunctionPtrHolder(
+ testUncontended<std::shared_mutex,
+ LockerWrapper<std::unique_lock<std::shared_mutex>>>);
+#endif
#if defined __cpp_lib_shared_timed_mutex
QTest::newRow("std::shared_timed_mutex, read") << FunctionPtrHolder(
testUncontended<std::shared_timed_mutex,
@@ -130,7 +142,7 @@ void testReadOnly()
struct Thread : QThread
{
Mutex *lock;
- void run()
+ void run() override
{
for (int i = 0; i < Iterations; ++i) {
QString s = QString::number(i); // Do something outside the lock
@@ -140,21 +152,20 @@ void testReadOnly()
}
};
Mutex lock;
- QVector<QThread *> threads;
+ std::vector<std::unique_ptr<Thread>> threads;
for (int i = 0; i < threadCount; ++i) {
- auto t = new Thread;
+ auto t = qt_make_unique<Thread>();
t->lock = &lock;
- threads.append(t);
+ threads.push_back(std::move(t));
}
QBENCHMARK {
- for (auto t : threads) {
+ for (auto &t : threads) {
t->start();
}
- for (auto t : threads) {
+ for (auto &t : threads) {
t->wait();
}
}
- qDeleteAll(threads);
}
void tst_QReadWriteLock::readOnly_data()
@@ -166,6 +177,11 @@ void tst_QReadWriteLock::readOnly_data()
QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testReadOnly<QReadWriteLock, QReadLocker>);
QTest::newRow("std::mutex") << FunctionPtrHolder(
testReadOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#ifdef __cpp_lib_shared_mutex
+ QTest::newRow("std::shared_mutex") << FunctionPtrHolder(
+ testReadOnly<std::shared_mutex,
+ LockerWrapper<std::shared_lock<std::shared_mutex>>>);
+#endif
#if defined __cpp_lib_shared_timed_mutex
QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder(
testReadOnly<std::shared_timed_mutex,
@@ -179,5 +195,66 @@ void tst_QReadWriteLock::readOnly()
holder.value();
}
+static QString global_string;
+
+template <typename Mutex, typename Locker>
+void testWriteOnly()
+{
+ struct Thread : QThread
+ {
+ Mutex *lock;
+ void run() override
+ {
+ for (int i = 0; i < Iterations; ++i) {
+ QString s = QString::number(i); // Do something outside the lock
+ Locker locker(lock);
+ global_string = s;
+ }
+ }
+ };
+ Mutex lock;
+ std::vector<std::unique_ptr<Thread>> threads;
+ for (int i = 0; i < threadCount; ++i) {
+ auto t = qt_make_unique<Thread>();
+ t->lock = &lock;
+ threads.push_back(std::move(t));
+ }
+ QBENCHMARK {
+ for (auto &t : threads) {
+ t->start();
+ }
+ for (auto &t : threads) {
+ t->wait();
+ }
+ }
+}
+
+void tst_QReadWriteLock::writeOnly_data()
+{
+ QTest::addColumn<FunctionPtrHolder>("holder");
+
+ // QTest::newRow("nothing") << FunctionPtrHolder(testWriteOnly<int, FakeLock>);
+ QTest::newRow("QMutex") << FunctionPtrHolder(testWriteOnly<QMutex, QMutexLocker>);
+ QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testWriteOnly<QReadWriteLock, QWriteLocker>);
+ QTest::newRow("std::mutex") << FunctionPtrHolder(
+ testWriteOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#ifdef __cpp_lib_shared_mutex
+ QTest::newRow("std::shared_mutex") << FunctionPtrHolder(
+ testWriteOnly<std::shared_mutex,
+ LockerWrapper<std::unique_lock<std::shared_mutex>>>);
+#endif
+#if defined __cpp_lib_shared_timed_mutex
+ QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder(
+ testWriteOnly<std::shared_timed_mutex,
+ LockerWrapper<std::unique_lock<std::shared_timed_mutex>>>);
+#endif
+}
+
+void tst_QReadWriteLock::writeOnly()
+{
+ QFETCH(FunctionPtrHolder, holder);
+ holder.value();
+}
+
QTEST_MAIN(tst_QReadWriteLock)
#include "tst_qreadwritelock.moc"
diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
index b88669e9ce..b8afb3bc05 100644
--- a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
+++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
@@ -342,6 +342,7 @@ void tst_QImageConversion::convertGenericInplace_data()
QImage argb6666 = argb32.convertToFormat(QImage::Format_ARGB6666_Premultiplied);
QImage argb4444 = argb32.convertToFormat(QImage::Format_ARGB4444_Premultiplied);
QImage rgb16 = argb32.convertToFormat(QImage::Format_RGB16);
+ QImage rgb30 = argb32.convertToFormat(QImage::Format_RGB30);
QImage rgb888 = argb32.convertToFormat(QImage::Format_RGB888);
QTest::newRow("argb32 -> argb32pm -> argb32") << argb32 << QImage::Format_ARGB32_Premultiplied;
@@ -370,6 +371,7 @@ void tst_QImageConversion::convertGenericInplace_data()
QTest::newRow("rgb16 -> rgb444 -> rgb16") << rgb16 << QImage::Format_RGB444;
QTest::newRow("rgb16 -> argb4444pm -> rgb16") << rgb16 << QImage::Format_ARGB4444_Premultiplied;
+ QTest::newRow("rgb30 -> bgr30 -> rgb30") << rgb30 << QImage::Format_BGR30;
QTest::newRow("rgb888 -> bgr888 -> rgb888") << rgb888 << QImage::Format_BGR888;
}
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
index c182ef7ebf..6dd7eaee6b 100644
--- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -544,15 +544,10 @@ void tst_qnetworkreply::echoPerformance()
void tst_qnetworkreply::preConnectEncrypted()
{
QFETCH(int, sleepTime);
- QFETCH(QSslConfiguration, sslConfiguration);
- bool spdyEnabled = !sslConfiguration.isNull();
-
QString hostName = QLatin1String("www.google.com");
QNetworkAccessManager manager;
QNetworkRequest request(QUrl("https://" + hostName));
- if (spdyEnabled)
- request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);
// make sure we have a full request including
// DNS lookup, TCP and SSL handshakes
@@ -578,12 +573,7 @@ void tst_qnetworkreply::preConnectEncrypted()
manager.clearAccessCache();
// now try to make the connection beforehand
- if (spdyEnabled) {
- request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);
- manager.connectToHostEncrypted(hostName, 443, sslConfiguration);
- } else {
- manager.connectToHostEncrypted(hostName);
- }
+ manager.connectToHostEncrypted(hostName);
QTestEventLoop::instance().enterLoopMSecs(sleepTime);
// now make another request and hopefully use the existing connection
@@ -591,8 +581,6 @@ void tst_qnetworkreply::preConnectEncrypted()
QNetworkReply *preConnectReply = normalResult.first;
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(preConnectReply->error() == QNetworkReply::NoError);
- bool spdyWasUsed = preConnectReply->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool();
- QCOMPARE(spdyEnabled, spdyWasUsed);
qint64 preConnectElapsed = preConnectResult.second;
qDebug() << request.url().toString() << "full request:" << normalElapsed
<< "ms, pre-connect request:" << preConnectElapsed << "ms, difference:"
@@ -605,27 +593,11 @@ void tst_qnetworkreply::preConnectEncrypted_data()
{
#ifndef QT_NO_OPENSSL
QTest::addColumn<int>("sleepTime");
- QTest::addColumn<QSslConfiguration>("sslConfiguration");
-
// start a new normal request after preconnecting is done
- QTest::newRow("HTTPS-2secs") << 2000 << QSslConfiguration();
+ QTest::newRow("HTTPS-2secs") << 2000;
// start a new normal request while preconnecting is in-flight
- QTest::newRow("HTTPS-100ms") << 100 << QSslConfiguration();
-
- QSslConfiguration spdySslConf = QSslConfiguration::defaultConfiguration();
- QList<QByteArray> nextProtocols = QList<QByteArray>()
- << QSslConfiguration::NextProtocolSpdy3_0
- << QSslConfiguration::NextProtocolHttp1_1;
- spdySslConf.setAllowedNextProtocols(nextProtocols);
-
-#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
- // start a new SPDY request while preconnecting is done
- QTest::newRow("SPDY-2secs") << 2000 << spdySslConf;
-
- // start a new SPDY request while preconnecting is in-flight
- QTest::newRow("SPDY-100ms") << 100 << spdySslConf;
-#endif // defined (QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ...
+ QTest::newRow("HTTPS-100ms") << 100;
#endif // QT_NO_OPENSSL
}
diff --git a/tests/benchmarks/network/socket/qudpsocket/qudpsocket.pro b/tests/benchmarks/network/socket/qudpsocket/qudpsocket.pro
new file mode 100644
index 0000000000..8df5340e2e
--- /dev/null
+++ b/tests/benchmarks/network/socket/qudpsocket/qudpsocket.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET = tst_bench_qudpsocket
+
+QT = network testlib
+
+CONFIG += release
+
+SOURCES += tst_qudpsocket.cpp
diff --git a/tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp
new file mode 100644
index 0000000000..e6dbbf9dfa
--- /dev/null
+++ b/tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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/qglobal.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtNetwork/qudpsocket.h>
+#include <QtNetwork/qnetworkdatagram.h>
+
+class tst_QUdpSocket : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QUdpSocket();
+
+private slots:
+ void pendingDatagramSize_data();
+ void pendingDatagramSize();
+};
+
+tst_QUdpSocket::tst_QUdpSocket()
+{
+}
+
+void tst_QUdpSocket::pendingDatagramSize_data()
+{
+ QTest::addColumn<int>("size");
+ for (int value : {52, 1024, 2049, 4500, 4098, 8192, 12000, 25000, 32 * 1024, 63 * 1024})
+ QTest::addRow("%d", value) << value;
+}
+
+void tst_QUdpSocket::pendingDatagramSize()
+{
+ QFETCH(int, size);
+ QUdpSocket socket;
+ socket.bind();
+
+ QNetworkDatagram datagram;
+ datagram.setData(QByteArray(size, 'a'));
+ datagram.setDestination(QHostAddress::SpecialAddress::LocalHost, socket.localPort());
+
+ auto sent = socket.writeDatagram(datagram);
+ QCOMPARE(sent, size);
+
+ auto res = QTest::qWaitFor([&socket]() { return socket.hasPendingDatagrams(); }, 5000);
+ QVERIFY(res);
+
+ QBENCHMARK {
+ auto pendingSize = socket.pendingDatagramSize();
+ Q_UNUSED(pendingSize);
+ }
+}
+
+QTEST_MAIN(tst_QUdpSocket)
+#include "tst_qudpsocket.moc"
diff --git a/tests/benchmarks/network/socket/socket.pro b/tests/benchmarks/network/socket/socket.pro
index 2d676a2c6e..d428a4d973 100644
--- a/tests/benchmarks/network/socket/socket.pro
+++ b/tests/benchmarks/network/socket/socket.pro
@@ -1,3 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
- qtcpserver
+ qtcpserver \
+ qudpsocket
diff --git a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
index c5ca6ed669..33875f1837 100644
--- a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
+++ b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
@@ -238,9 +238,6 @@ void tst_QSqlQuery::benchmark()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- QSKIP( "Test requires MySQL >= 5.0");
-
QSqlQuery q(db);
const QString tableName(qTableName("benchmark", __FILE__, db));
@@ -266,9 +263,6 @@ void tst_QSqlQuery::benchmarkSelectPrepared()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 0).toInt() < 5)
- QSKIP("Test requires MySQL >= 5.0");
-
QSqlQuery q(db);
const QString tableName(qTableName("benchmark", __FILE__, db));