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>
This commit is contained in:
Peter Hartmann 2013-02-13 15:58:12 +01:00 committed by The Qt Project
parent c4314f7aeb
commit 08f8027a0e

View File

@ -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)