summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp')
-rw-r--r--tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp60
1 files changed, 18 insertions, 42 deletions
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
index c548811c64..bab2743513 100644
--- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// This file contains benchmarks for QNetworkReply functions.
#include <QDebug>
@@ -44,11 +19,10 @@
#ifdef QT_BUILD_INTERNAL
#include <QtNetwork/private/qhostinfo_p.h>
-#ifndef QT_NO_OPENSSL
-#include <QtNetwork/private/qsslsocket_openssl_p.h>
-#endif
#endif
+using namespace std::chrono_literals;
+
Q_DECLARE_METATYPE(QSharedPointer<char>)
class TimedSender: public QThread
@@ -484,7 +458,7 @@ void tst_qnetworkreply::httpLatency()
QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/"));
QNetworkReply* reply = manager.get(request);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
- QTestEventLoop::instance().enterLoop(5);
+ QTestEventLoop::instance().enterLoop(5s);
QVERIFY(!QTestEventLoop::instance().timeout());
delete reply;
}
@@ -498,7 +472,7 @@ QPair<QNetworkReply *, qint64> tst_qnetworkreply::runGetRequest(
QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors()));
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
- QTestEventLoop::instance().enterLoop(20);
+ QTestEventLoop::instance().enterLoop(20s);
qint64 elapsed = timer.elapsed();
return qMakePair(reply, elapsed);
}
@@ -529,7 +503,7 @@ void tst_qnetworkreply::echoPerformance()
QNetworkReply* reply = manager.post(request, data);
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors()));
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
- QTestEventLoop::instance().enterLoop(5);
+ QTestEventLoop::instance().enterLoop(5s);
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(reply->error() == QNetworkReply::NoError);
delete reply;
@@ -538,7 +512,7 @@ void tst_qnetworkreply::echoPerformance()
void tst_qnetworkreply::preConnectEncrypted()
{
- QFETCH(int, sleepTime);
+ QFETCH(std::chrono::milliseconds, sleepTime);
QString hostName = QLatin1String("www.google.com");
QNetworkAccessManager manager;
@@ -569,7 +543,7 @@ void tst_qnetworkreply::preConnectEncrypted()
// now try to make the connection beforehand
manager.connectToHostEncrypted(hostName);
- QTestEventLoop::instance().enterLoopMSecs(sleepTime);
+ QTestEventLoop::instance().enterLoop(sleepTime);
// now make another request and hopefully use the existing connection
QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request);
@@ -587,12 +561,12 @@ void tst_qnetworkreply::preConnectEncrypted()
void tst_qnetworkreply::preConnectEncrypted_data()
{
#ifndef QT_NO_OPENSSL
- QTest::addColumn<int>("sleepTime");
+ QTest::addColumn<std::chrono::milliseconds>("sleepTime");
// start a new normal request after preconnecting is done
- QTest::newRow("HTTPS-2secs") << 2000;
+ QTest::newRow("HTTPS-2secs") << 2000ms;
// start a new normal request while preconnecting is in-flight
- QTest::newRow("HTTPS-100ms") << 100;
+ QTest::newRow("HTTPS-100ms") << 100ms;
#endif // QT_NO_OPENSSL
}
@@ -634,9 +608,11 @@ void tst_qnetworkreply::uploadPerformance()
QVERIFY(!QTestEventLoop::instance().timeout());
}
+constexpr qint64 MiB = 1024 * 1024;
+
void tst_qnetworkreply::httpUploadPerformance()
{
- enum {UploadSize = 128*1024*1024}; // 128 MB
+ constexpr qint64 UploadSize = 128 * MiB;
ThreadedDataReaderHttpServer reader;
FixedSizeDataGenerator generator(UploadSize);
@@ -704,7 +680,7 @@ void tst_qnetworkreply::httpDownloadPerformance()
QFETCH(bool, serverSendsContentLength);
QFETCH(bool, chunkedEncoding);
- enum {UploadSize = 128*1024*1024}; // 128 MB
+ constexpr qint64 UploadSize = 128 * MiB;
HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);
@@ -941,9 +917,9 @@ void tst_qnetworkreply::preConnect()
manager.clearAccessCache();
// now try to make the connection beforehand
- QFETCH(int, sleepTime);
+ QFETCH(std::chrono::milliseconds, sleepTime);
manager.connectToHost(hostName);
- QTestEventLoop::instance().enterLoopMSecs(sleepTime);
+ QTestEventLoop::instance().enterLoop(sleepTime);
// now make another request and hopefully use the existing connection
QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request);