From 1806ea8dd9c5849ea70389d5c3baf66137242d8e Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 20 Jan 2012 01:54:43 +0200 Subject: Add the capability to use multiple data sources for qhash benchmark. More data sources to be added in followup commits. Change-Id: I0393119b36ac5d88fc2c5c8d46b000d13d5ca996 Reviewed-by: Richard J. Moore --- tests/benchmarks/corelib/tools/qhash/data.txt | 195 --------------------- tests/benchmarks/corelib/tools/qhash/main.cpp | 51 +++--- .../corelib/tools/qhash/paths_small_data.txt | 195 +++++++++++++++++++++ 3 files changed, 226 insertions(+), 215 deletions(-) delete mode 100644 tests/benchmarks/corelib/tools/qhash/data.txt create mode 100644 tests/benchmarks/corelib/tools/qhash/paths_small_data.txt (limited to 'tests/benchmarks/corelib/tools/qhash') diff --git a/tests/benchmarks/corelib/tools/qhash/data.txt b/tests/benchmarks/corelib/tools/qhash/data.txt deleted file mode 100644 index d5acd28820..0000000000 --- a/tests/benchmarks/corelib/tools/qhash/data.txt +++ /dev/null @@ -1,195 +0,0 @@ -. -./corelib.pro -./kernel -./kernel/kernel.pro -./kernel/qobject -./kernel/qobject/main.cpp -./kernel/qobject/object.cpp -./kernel/qobject/object.h -./kernel/qobject/Makefile -./kernel/qobject/qobject.pro -./kernel/qvariant -./kernel/qvariant/tst_qvariant.cpp -./kernel/qvariant/Makefile -./kernel/qvariant/qvariant.pro -./kernel/qtimer_vs_qmetaobject -./kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp -./kernel/qtimer_vs_qmetaobject/Makefile -./kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro -./kernel/.pch -./kernel/.pch/debug-shared -./kernel/qmetaobject -./kernel/qmetaobject/main.cpp -./kernel/qmetaobject/qmetaobject.pro -./kernel/qmetaobject/Makefile -./kernel/Makefile -./kernel/.obj -./kernel/.obj/debug-shared -./kernel/events -./kernel/events/events.pro -./kernel/events/main.cpp -./kernel/events/Makefile -./kernel/qmetatype -./kernel/qmetatype/qmetatype.pro -./kernel/qmetatype/Makefile -./kernel/qmetatype/tst_qmetatype.cpp -./codecs -./codecs/qtextcodec -./codecs/qtextcodec/qtextcodec.pro -./codecs/qtextcodec/main.cpp -./codecs/qtextcodec/Makefile -./codecs/qtextcodec/utf-8.txt -./codecs/codecs.pro -./codecs/.pch -./codecs/.pch/debug-shared -./codecs/Makefile -./codecs/.obj -./codecs/.obj/debug-shared -./.pch -./.pch/debug-shared -./tools -./tools/tools.pro -./tools/qregexp -./tools/qregexp/qregexp.qrc -./tools/qregexp/main.cpp -./tools/qregexp/Makefile -./tools/qregexp/qregexp.pro -./tools/qvector -./tools/qvector/tst_vector -./tools/qvector/.pch -./tools/qvector/.pch/debug-shared -./tools/qvector/qrawvector.h -./tools/qvector/main.cpp -./tools/qvector/Makefile -./tools/qvector/.moc -./tools/qvector/.moc/release-shared -./tools/qvector/.moc/release-shared/main.moc -./tools/qvector/.obj -./tools/qvector/.obj/release-shared -./tools/qvector/.obj/release-shared/outofline.o -./tools/qvector/.obj/release-shared/main.o -./tools/qvector/outofline.cpp -./tools/qvector/qvector.pro -./tools/.pch -./tools/.pch/debug-shared -./tools/qstringbuilder -./tools/qstringbuilder/main.cpp -./tools/qstringbuilder/Makefile -./tools/qstringbuilder/qstringbuilder.pro -./tools/containers-sequential -./tools/containers-sequential/containers-sequential.pro -./tools/containers-sequential/main.cpp -./tools/containers-sequential/Makefile -./tools/qstring -./tools/qstring/generatelist.pl -./tools/qstring/data.h -./tools/qstring/qstring.pro -./tools/qstring/main.cpp -./tools/qstring/data.cpp -./tools/qstring/Makefile -./tools/qstring/utf-8.txt -./tools/qstringlist -./tools/qstringlist/qstringlist.pro -./tools/qstringlist/main.cpp -./tools/qstringlist/.gitignore -./tools/qstringlist/Makefile -./tools/qbytearray -./tools/qbytearray/qbytearray.pro -./tools/qbytearray/main.cpp -./tools/qbytearray/Makefile -./tools/containers-associative -./tools/containers-associative/containers-associative.pro -./tools/containers-associative/main.cpp -./tools/containers-associative/Makefile -./tools/qrect -./tools/qrect/main.cpp -./tools/qrect/Makefile -./tools/qrect/qrect.pro -./tools/Makefile -./tools/qhash -./tools/qhash/data.txt -./tools/qhash/qhash_string.cpp -./tools/qhash/.qhash_string.cpp.swp -./tools/qhash/qhash.pro -./tools/qhash/outofline.cpp -./tools/.obj -./tools/.obj/debug-shared -./Makefile -./.obj -./.obj/debug-shared -./plugin -./plugin/plugin.pro -./plugin/.pch -./plugin/.pch/debug-shared -./plugin/Makefile -./plugin/.obj -./plugin/.obj/debug-shared -./plugin/quuid -./plugin/quuid/tst_quuid.cpp -./plugin/quuid/quuid.pro -./plugin/quuid/Makefile -./io -./io/qtemporaryfile -./io/qtemporaryfile/qtemporaryfile.pro -./io/qtemporaryfile/main.cpp -./io/qtemporaryfile/Makefile -./io/qiodevice -./io/qiodevice/qiodevice.pro -./io/qiodevice/main.cpp -./io/qiodevice/Makefile -./io/qurl -./io/qurl/main.cpp -./io/qurl/Makefile -./io/qurl/qurl.pro -./io/qdir -./io/qdir/.pch -./io/qdir/.pch/debug-shared -./io/qdir/qdir.pro -./io/qdir/tree -./io/qdir/tree/bench_qdir_tree.qrc -./io/qdir/tree/tree.pro -./io/qdir/tree/4.6.0-list.txt -./io/qdir/tree/Makefile -./io/qdir/tree/bench_qdir_tree.cpp -./io/qdir/Makefile -./io/qdir/.obj -./io/qdir/.obj/debug-shared -./io/qdir/10000 -./io/qdir/10000/10000.pro -./io/qdir/10000/bench_qdir_10000.cpp -./io/qdir/10000/Makefile -./io/.pch -./io/.pch/debug-shared -./io/qfile -./io/qfile/qfile.pro -./io/qfile/main.cpp -./io/qfile/Makefile -./io/io.pro -./io/qfileinfo -./io/qfileinfo/qfileinfo.pro -./io/qfileinfo/main.cpp -./io/qfileinfo/Makefile -./io/qdiriterator -./io/qdiriterator/qfilesystemiterator.h -./io/qdiriterator/main.cpp -./io/qdiriterator/Makefile -./io/qdiriterator/qfilesystemiterator.cpp -./io/qdiriterator/qdiriterator.pro -./io/Makefile -./io/.obj -./io/.obj/debug-shared -./thread -./thread/qmutex -./thread/qmutex/tst_qmutex.cpp -./thread/qmutex/Makefile -./thread/qmutex/qmutex.pro -./thread/qthreadstorage -./thread/qthreadstorage/qthreadstorage.pro -./thread/qthreadstorage/Makefile -./thread/qthreadstorage/tst_qthreadstorage.cpp -./thread/.pch -./thread/.pch/debug-shared -./thread/Makefile -./thread/.obj -./thread/.obj/debug-shared -./thread/thread.pro diff --git a/tests/benchmarks/corelib/tools/qhash/main.cpp b/tests/benchmarks/corelib/tools/qhash/main.cpp index 412f071a99..f9aec58485 100644 --- a/tests/benchmarks/corelib/tools/qhash/main.cpp +++ b/tests/benchmarks/corelib/tools/qhash/main.cpp @@ -54,12 +54,15 @@ class tst_QHash : public QObject Q_OBJECT private slots: + void qhash_qt4_data() { data(); } void qhash_qt4(); + void qhash_faster_data() { data(); } void qhash_faster(); + void javaString_data() { data(); } void javaString(); private: - QString data(); + void data(); }; const int N = 1000000; @@ -67,49 +70,57 @@ extern double s; ///////////////////// QHash ///////////////////// -QString tst_QHash::data() +void tst_QHash::data() { - QFile file("data.txt"); - file.open(QIODevice::ReadOnly); - return QString::fromLatin1(file.readAll()); + QFile smallPathsData("paths_small_data.txt"); + smallPathsData.open(QIODevice::ReadOnly); + + QTest::addColumn("items"); + QTest::newRow("paths-small") + << QString::fromLatin1(smallPathsData.readAll()).split(QLatin1Char('\n')); } void tst_QHash::qhash_qt4() { - QStringList items = data().split(QLatin1Char('\n')); + QFETCH(QStringList, items); + QStringList realitems = items; // for copy/paste ease between benchmarks QHash hash; - + QBENCHMARK { - for (int i = 0, n = items.size(); i != n; ++i) { - hash[items.at(i)] = i; + for (int i = 0, n = realitems.size(); i != n; ++i) { + hash[realitems.at(i)] = i; } } } void tst_QHash::qhash_faster() { - QList items; - foreach (const QString &s, data().split(QLatin1Char('\n'))) - items.append(s); + QFETCH(QStringList, items); QHash hash; - + + QList realitems; + foreach (const QString &s, items) + realitems.append(s); + QBENCHMARK { - for (int i = 0, n = items.size(); i != n; ++i) { - hash[items.at(i)] = i; + for (int i = 0, n = realitems.size(); i != n; ++i) { + hash[realitems.at(i)] = i; } } } void tst_QHash::javaString() { - QList items; - foreach (const QString &s, data().split(QLatin1Char('\n'))) - items.append(s); + QFETCH(QStringList, items); QHash hash; + QList realitems; + foreach (const QString &s, items) + realitems.append(s); + QBENCHMARK { - for (int i = 0, n = items.size(); i != n; ++i) { - hash[items.at(i)] = i; + for (int i = 0, n = realitems.size(); i != n; ++i) { + hash[realitems.at(i)] = i; } } } diff --git a/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt b/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt new file mode 100644 index 0000000000..d5acd28820 --- /dev/null +++ b/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt @@ -0,0 +1,195 @@ +. +./corelib.pro +./kernel +./kernel/kernel.pro +./kernel/qobject +./kernel/qobject/main.cpp +./kernel/qobject/object.cpp +./kernel/qobject/object.h +./kernel/qobject/Makefile +./kernel/qobject/qobject.pro +./kernel/qvariant +./kernel/qvariant/tst_qvariant.cpp +./kernel/qvariant/Makefile +./kernel/qvariant/qvariant.pro +./kernel/qtimer_vs_qmetaobject +./kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp +./kernel/qtimer_vs_qmetaobject/Makefile +./kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro +./kernel/.pch +./kernel/.pch/debug-shared +./kernel/qmetaobject +./kernel/qmetaobject/main.cpp +./kernel/qmetaobject/qmetaobject.pro +./kernel/qmetaobject/Makefile +./kernel/Makefile +./kernel/.obj +./kernel/.obj/debug-shared +./kernel/events +./kernel/events/events.pro +./kernel/events/main.cpp +./kernel/events/Makefile +./kernel/qmetatype +./kernel/qmetatype/qmetatype.pro +./kernel/qmetatype/Makefile +./kernel/qmetatype/tst_qmetatype.cpp +./codecs +./codecs/qtextcodec +./codecs/qtextcodec/qtextcodec.pro +./codecs/qtextcodec/main.cpp +./codecs/qtextcodec/Makefile +./codecs/qtextcodec/utf-8.txt +./codecs/codecs.pro +./codecs/.pch +./codecs/.pch/debug-shared +./codecs/Makefile +./codecs/.obj +./codecs/.obj/debug-shared +./.pch +./.pch/debug-shared +./tools +./tools/tools.pro +./tools/qregexp +./tools/qregexp/qregexp.qrc +./tools/qregexp/main.cpp +./tools/qregexp/Makefile +./tools/qregexp/qregexp.pro +./tools/qvector +./tools/qvector/tst_vector +./tools/qvector/.pch +./tools/qvector/.pch/debug-shared +./tools/qvector/qrawvector.h +./tools/qvector/main.cpp +./tools/qvector/Makefile +./tools/qvector/.moc +./tools/qvector/.moc/release-shared +./tools/qvector/.moc/release-shared/main.moc +./tools/qvector/.obj +./tools/qvector/.obj/release-shared +./tools/qvector/.obj/release-shared/outofline.o +./tools/qvector/.obj/release-shared/main.o +./tools/qvector/outofline.cpp +./tools/qvector/qvector.pro +./tools/.pch +./tools/.pch/debug-shared +./tools/qstringbuilder +./tools/qstringbuilder/main.cpp +./tools/qstringbuilder/Makefile +./tools/qstringbuilder/qstringbuilder.pro +./tools/containers-sequential +./tools/containers-sequential/containers-sequential.pro +./tools/containers-sequential/main.cpp +./tools/containers-sequential/Makefile +./tools/qstring +./tools/qstring/generatelist.pl +./tools/qstring/data.h +./tools/qstring/qstring.pro +./tools/qstring/main.cpp +./tools/qstring/data.cpp +./tools/qstring/Makefile +./tools/qstring/utf-8.txt +./tools/qstringlist +./tools/qstringlist/qstringlist.pro +./tools/qstringlist/main.cpp +./tools/qstringlist/.gitignore +./tools/qstringlist/Makefile +./tools/qbytearray +./tools/qbytearray/qbytearray.pro +./tools/qbytearray/main.cpp +./tools/qbytearray/Makefile +./tools/containers-associative +./tools/containers-associative/containers-associative.pro +./tools/containers-associative/main.cpp +./tools/containers-associative/Makefile +./tools/qrect +./tools/qrect/main.cpp +./tools/qrect/Makefile +./tools/qrect/qrect.pro +./tools/Makefile +./tools/qhash +./tools/qhash/data.txt +./tools/qhash/qhash_string.cpp +./tools/qhash/.qhash_string.cpp.swp +./tools/qhash/qhash.pro +./tools/qhash/outofline.cpp +./tools/.obj +./tools/.obj/debug-shared +./Makefile +./.obj +./.obj/debug-shared +./plugin +./plugin/plugin.pro +./plugin/.pch +./plugin/.pch/debug-shared +./plugin/Makefile +./plugin/.obj +./plugin/.obj/debug-shared +./plugin/quuid +./plugin/quuid/tst_quuid.cpp +./plugin/quuid/quuid.pro +./plugin/quuid/Makefile +./io +./io/qtemporaryfile +./io/qtemporaryfile/qtemporaryfile.pro +./io/qtemporaryfile/main.cpp +./io/qtemporaryfile/Makefile +./io/qiodevice +./io/qiodevice/qiodevice.pro +./io/qiodevice/main.cpp +./io/qiodevice/Makefile +./io/qurl +./io/qurl/main.cpp +./io/qurl/Makefile +./io/qurl/qurl.pro +./io/qdir +./io/qdir/.pch +./io/qdir/.pch/debug-shared +./io/qdir/qdir.pro +./io/qdir/tree +./io/qdir/tree/bench_qdir_tree.qrc +./io/qdir/tree/tree.pro +./io/qdir/tree/4.6.0-list.txt +./io/qdir/tree/Makefile +./io/qdir/tree/bench_qdir_tree.cpp +./io/qdir/Makefile +./io/qdir/.obj +./io/qdir/.obj/debug-shared +./io/qdir/10000 +./io/qdir/10000/10000.pro +./io/qdir/10000/bench_qdir_10000.cpp +./io/qdir/10000/Makefile +./io/.pch +./io/.pch/debug-shared +./io/qfile +./io/qfile/qfile.pro +./io/qfile/main.cpp +./io/qfile/Makefile +./io/io.pro +./io/qfileinfo +./io/qfileinfo/qfileinfo.pro +./io/qfileinfo/main.cpp +./io/qfileinfo/Makefile +./io/qdiriterator +./io/qdiriterator/qfilesystemiterator.h +./io/qdiriterator/main.cpp +./io/qdiriterator/Makefile +./io/qdiriterator/qfilesystemiterator.cpp +./io/qdiriterator/qdiriterator.pro +./io/Makefile +./io/.obj +./io/.obj/debug-shared +./thread +./thread/qmutex +./thread/qmutex/tst_qmutex.cpp +./thread/qmutex/Makefile +./thread/qmutex/qmutex.pro +./thread/qthreadstorage +./thread/qthreadstorage/qthreadstorage.pro +./thread/qthreadstorage/Makefile +./thread/qthreadstorage/tst_qthreadstorage.cpp +./thread/.pch +./thread/.pch/debug-shared +./thread/Makefile +./thread/.obj +./thread/.obj/debug-shared +./thread/thread.pro -- cgit v1.2.3