summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/network
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2011-07-01 15:15:21 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-06 12:03:30 +0200
commitceceb3796fbfdcd944fc7da7c8b2198fca69cb44 (patch)
tree1c8517ed47abf66c9316af256646fea643a843d4 /tests/benchmarks/network
parent5d9818e7b61ca47a1566ba15baed647879d9dcda (diff)
QNetworkReply benchmark: Benchmark a chain of SSL requests
Change-Id: Ic74b4189c5b8e7fc8f86d76973d628c63989d32d Reviewed-on: http://codereview.qt.nokia.com/1010 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'tests/benchmarks/network')
-rw-r--r--tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
index dc06e420fd..d96b110d54 100644
--- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -469,6 +469,7 @@ private slots:
void httpDownloadPerformance();
void httpDownloadPerformanceDownloadBuffer_data();
void httpDownloadPerformanceDownloadBuffer();
+ void httpsRequestChain();
};
void tst_qnetworkreply::httpLatency()
@@ -739,6 +740,87 @@ void tst_qnetworkreply::httpDownloadPerformanceDownloadBuffer()
}
}
+
+class HttpsRequestChainHelper : public QObject {
+ Q_OBJECT
+public:
+ QList<QNetworkRequest> requestList;
+
+ QElapsedTimer timeOneRequest;
+ QList<qint64> timeList;
+
+ QElapsedTimer globalTime;
+
+ QNetworkAccessManager manager;
+
+ HttpsRequestChainHelper() {
+ }
+public slots:
+ void doNextRequest() {
+ // all requests done
+ if (requestList.isEmpty()) {
+ QTestEventLoop::instance().exitLoop();
+ return;
+ }
+
+ if (qobject_cast<QNetworkReply*>(sender()) == 0) {
+ // first start after DNS lookup, start timer
+ globalTime.start();
+ }
+ QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
+ if (reply) {
+ QVERIFY(reply->error() == QNetworkReply::NoError);
+ qDebug() << "time =" << timeOneRequest.elapsed() << "ms";
+ timeList.append(timeOneRequest.elapsed());
+ }
+
+ QNetworkRequest request = requestList.takeFirst();
+ timeOneRequest.restart();
+ reply = manager.get(request);
+ QObject::connect(reply, SIGNAL(sslErrors( const QList<QSslError> &)), reply, SLOT(ignoreSslErrors()));
+ QObject::connect(reply, SIGNAL(finished()), this, SLOT(doNextRequest()));
+ }
+
+};
+
+void tst_qnetworkreply::httpsRequestChain()
+{
+ int count = 10;
+
+ QNetworkRequest request(QUrl("https://" + QtNetworkSettings::serverName() + "/fluke.gif"));
+ //QNetworkRequest request(QUrl("https://www.nokia.com/robots.txt"));
+ // Disable keep-alive so we have the full re-connecting of TCP.
+ request.setRawHeader("Connection", "close");
+
+ HttpsRequestChainHelper helper;
+ for (int i = 0; i < count; i++)
+ helper.requestList.append(request);
+
+ // Warm up DNS cache and then immediatly start HTTP
+ QHostInfo::lookupHost(QtNetworkSettings::serverName(), &helper, SLOT(doNextRequest()));
+ //QHostInfo::lookupHost("www.nokia.com", &helper, SLOT(doNextRequest()));
+
+ // we can use QBENCHMARK_ONCE when we find out how to make it really run once.
+ // there is still a warmup-run :(
+
+ //QBENCHMARK_ONCE {
+ QTestEventLoop::instance().enterLoop(40);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ //}
+
+ qint64 elapsed = helper.globalTime.elapsed();
+
+ qint64 average = (elapsed / count);
+
+ qSort(helper.timeList);
+ qint64 median = helper.timeList.at(5);
+
+ qDebug() << "Total:" << elapsed << " Average:" << average << " Median:" << median;
+
+}
+
+
+
QTEST_MAIN(tst_qnetworkreply)
#include "tst_qnetworkreply.moc"