From ce7f914e8db0cad698d934569f1c323e5b231bc9 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 4 Mar 2010 13:52:03 +0100 Subject: qhostinfo benchmark: Benchmark the with-cache and without-cache Reviewed-by: joao --- tests/benchmarks/network/kernel/qhostinfo/main.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/benchmarks/network/kernel/qhostinfo/main.cpp b/tests/benchmarks/network/kernel/qhostinfo/main.cpp index 0ae1b7f..ebdea5e 100644 --- a/tests/benchmarks/network/kernel/qhostinfo/main.cpp +++ b/tests/benchmarks/network/kernel/qhostinfo/main.cpp @@ -48,9 +48,14 @@ #include #include +#include "private/qhostinfo_p.h" + class tst_qhostinfo : public QObject { Q_OBJECT +public slots: + void initTestCase(); + void init(); private slots: void lookupSpeed(); }; @@ -70,14 +75,38 @@ public slots: } }; +void tst_qhostinfo::initTestCase() +{ + // run each testcase with and without cache enabled + QTest::addColumn("cache"); + QTest::newRow("WithCache") << true; + QTest::newRow("WithoutCache") << false; +} + +void tst_qhostinfo::init() +{ + // delete the cache so inidividual testcase results are independant from each other + qt_qhostinfo_clear_cache(); + + QFETCH_GLOBAL(bool, cache); + qt_qhostinfo_enable_cache(cache); +} + + void tst_qhostinfo::lookupSpeed() { + QFETCH_GLOBAL(bool, cache); + qDebug() << "Cache enabled:" << cache; + QStringList hostnameList; hostnameList << "www.ovi.com" << "www.nokia.com" << "qt.nokia.com" << "www.trolltech.com" << "troll.no" << "www.qtcentre.org" << "forum.nokia.com" << "www.forum.nokia.com" << "wiki.forum.nokia.com" << "www.nokia.no" << "nokia.de" << "127.0.0.1" << "----"; // also add some duplicates: hostnameList << "www.nokia.com" << "127.0.0.1" << "www.trolltech.com"; + // and some more + hostnameList << hostnameList; + const int COUNT = hostnameList.size(); SignalReceiver receiver(COUNT); -- cgit v0.12