diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-10-19 15:16:20 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-10-20 08:09:59 (GMT) |
commit | 5fd8c58dde0c61a723ab124ac74c863f67288a14 (patch) | |
tree | 720e6262c688896a597ad1760084d4e871b1501a /tests/benchmarks | |
parent | 9d91a56ad5e39ddb237e10819a371e78defdf359 (diff) | |
download | Qt-5fd8c58dde0c61a723ab124ac74c863f67288a14.zip Qt-5fd8c58dde0c61a723ab124ac74c863f67288a14.tar.gz Qt-5fd8c58dde0c61a723ab124ac74c863f67288a14.tar.bz2 |
Add a up/down benchmark to benchmarks/qnetworkreply
Reviewed-by: Peter Hartmann
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp index 666e4f1..e622d62 100644 --- a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -53,7 +53,10 @@ class tst_qnetworkreply : public QObject Q_OBJECT private slots: void httpLatency(); - +#ifndef QT_NO_OPENSSL + void echoPerformance_data(); + void echoPerformance(); +#endif }; void tst_qnetworkreply::httpLatency() @@ -69,6 +72,40 @@ void tst_qnetworkreply::httpLatency() } } +#ifndef QT_NO_OPENSSL +void tst_qnetworkreply::echoPerformance_data() +{ + QTest::addColumn<bool>("ssl"); + QTest::newRow("no_ssl") << false; + QTest::newRow("ssl") << true; +} + +void tst_qnetworkreply::echoPerformance() +{ + QFETCH(bool, ssl); + QNetworkAccessManager manager; + QNetworkRequest request(QUrl((ssl ? "https://" : "http://") + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi")); + + QByteArray data; + data.resize(1024*1024*10); // 10 MB + // init with garbage. needed so ssl cannot compress it in an efficient way. + for (int i = 0; i < data.size() / sizeof(int); i++) { + int r = qrand(); + data.data()[i*sizeof(int)] = r; + } + + QBENCHMARK{ + QNetworkReply* reply = manager.post(request, data); + connect(reply, SIGNAL(sslErrors( const QList<QSslError> &)), reply, SLOT(ignoreSslErrors())); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(reply->error() == QNetworkReply::NoError); + delete reply; + } +} +#endif + QTEST_MAIN(tst_qnetworkreply) #include "main.moc" |