diff options
author | Peter Hartmann <phartmann@rim.com> | 2013-02-13 15:58:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-16 09:28:24 +0100 |
commit | 08f8027a0eb75c2dc0e6ad885c65e35008c728b3 (patch) | |
tree | a68d64562332c2e56e9e52606547ec20e95c0b3a /tests/benchmarks/network | |
parent | c4314f7aeb35568cc7f88fe94420c01f74f670a5 (diff) |
SSL benchmarks: add benchmark for uploading data
All Web service APIs like Facebook, Twitter etc. use SSL for
uploading pictures etc., so it is good to have a benchmark
for that.
Task-number: QTBUG-28764
Change-Id: I590f76ac8b6575509f1635c18c35f9fe652fa8f8
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests/benchmarks/network')
-rw-r--r-- | tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index e653e8dffb..f62ce6bf5c 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -471,6 +471,10 @@ private slots: void httpDownloadPerformanceDownloadBuffer_data(); void httpDownloadPerformanceDownloadBuffer(); void httpsRequestChain(); + void httpsUpload(); + +private: + void runHttpsUploadRequest(const QByteArray &data, const QNetworkRequest &request); }; void tst_qnetworkreply::initTestCase() @@ -825,6 +829,28 @@ void tst_qnetworkreply::httpsRequestChain() } +void tst_qnetworkreply::runHttpsUploadRequest(const QByteArray &data, const QNetworkRequest &request) +{ + QNetworkReply* reply = manager.post(request, data); + reply->ignoreSslErrors(); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(15); + QVERIFY(!QTestEventLoop::instance().timeout()); + QCOMPARE(reply->error(), QNetworkReply::NoError); + reply->deleteLater(); +} + +void tst_qnetworkreply::httpsUpload() +{ + QByteArray data = QByteArray(2*1024*1024+1, '\177'); + QNetworkRequest request(QUrl("https://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi")); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream"); +// for (int a = 0; a < 10; ++a) +// runHttpsUploadRequest(data, request); // to warmup all TCP connections + QBENCHMARK { + runHttpsUploadRequest(data, request); + } +} QTEST_MAIN(tst_qnetworkreply) |