summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-01-18 14:46:29 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-01-18 15:48:03 (GMT)
commit330e852641121c0dddf2e9ac7dc6a7bafb5432dd (patch)
tree7cb47764df1c5d987da9befc66e74d423655824f /tests/benchmarks
parentb5d3b999fa9c52246c8d4e4c1389df105d96cced (diff)
downloadQt-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/benchmarks')
-rw-r--r--tests/benchmarks/qfile_vs_qnetworkaccessmanager/main.cpp35
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();