diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-18 14:46:29 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-18 15:48:03 (GMT) |
commit | 330e852641121c0dddf2e9ac7dc6a7bafb5432dd (patch) | |
tree | 7cb47764df1c5d987da9befc66e74d423655824f /tests | |
parent | b5d3b999fa9c52246c8d4e4c1389df105d96cced (diff) | |
download | Qt-330e852641121c0dddf2e9ac7dc6a7bafb5432dd.zip Qt-330e852641121c0dddf2e9ac7dc6a7bafb5432dd.tar.gz Qt-330e852641121c0dddf2e9ac7dc6a7bafb5432dd.tar.bz2 |
Extend qfile_vs_qnetworkaccessmanager benchmark
We need a third one to benchmark the without-event-loop use case
that we now provide.
Reviewed-by: TrustMe
Diffstat (limited to 'tests')
-rw-r--r-- | tests/benchmarks/qfile_vs_qnetworkaccessmanager/main.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/benchmarks/qfile_vs_qnetworkaccessmanager/main.cpp b/tests/benchmarks/qfile_vs_qnetworkaccessmanager/main.cpp index 907ffb7..23e07db 100644 --- a/tests/benchmarks/qfile_vs_qnetworkaccessmanager/main.cpp +++ b/tests/benchmarks/qfile_vs_qnetworkaccessmanager/main.cpp @@ -55,11 +55,13 @@ class qfile_vs_qnetworkaccessmanager : public QObject // but.. this is a manual test anyway, so :) protected: void qnamFileRead_iteration(QNetworkAccessManager &manager, QNetworkRequest &request); + void qnamImmediateFileRead_iteration(QNetworkAccessManager &manager, QNetworkRequest &request); void qfileFileRead_iteration(); static const int iterations = 10; private slots: void qnamFileRead(); + void qnamImmediateFileRead(); void qfileFileRead(); void initTestCase(); @@ -124,6 +126,39 @@ void qfile_vs_qnetworkaccessmanager::qnamFileRead() qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } +void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead_iteration(QNetworkAccessManager &manager, QNetworkRequest &request) +{ + QNetworkReply* reply = manager.get(request); + QVERIFY(reply->isFinished()); // should be like that! + QByteArray qba = reply->readAll(); + delete reply; +} + +void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead() +{ + QNetworkAccessManager manager; + QTime t; + QNetworkRequest request(QUrl(testFile.fileName())); + + // do 3 dry runs for cache warmup + qnamImmediateFileRead_iteration(manager, request); + qnamImmediateFileRead_iteration(manager, request); + qnamImmediateFileRead_iteration(manager, request); + + t.start(); + // 10 real runs + QBENCHMARK_ONCE { + for (int i = 0; i < iterations; i++) { + qnamImmediateFileRead_iteration(manager, request); + } + } + + qint64 elapsed = t.elapsed(); + qDebug() << endl << "Finished!"; + qDebug() << "Bytes:" << size; + qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; +} + void qfile_vs_qnetworkaccessmanager::qfileFileRead_iteration() { testFile.reset(); |