diff options
author | hjk <qtc-committer@nokia.com> | 2009-12-15 10:58:19 (GMT) |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2009-12-15 11:00:34 (GMT) |
commit | 7cd3470c65cd17c4511d757daf1506932d77db13 (patch) | |
tree | 43a225a3a5af951e73addf2e9f208c3728afeba1 /tests | |
parent | fcf91a2d527b393a366c997dd225c076afe34718 (diff) | |
download | Qt-7cd3470c65cd17c4511d757daf1506932d77db13.zip Qt-7cd3470c65cd17c4511d757daf1506932d77db13.tar.gz Qt-7cd3470c65cd17c4511d757daf1506932d77db13.tar.bz2 |
work on QStringList split/join benchmark
Diffstat (limited to 'tests')
-rw-r--r-- | tests/benchmarks/qstringlist/main.cpp | 67 | ||||
-rw-r--r-- | tests/benchmarks/qstringlist/qstringlist.pro | 2 |
2 files changed, 46 insertions, 23 deletions
diff --git a/tests/benchmarks/qstringlist/main.cpp b/tests/benchmarks/qstringlist/main.cpp index a2a1dd5..85bfb5f 100644 --- a/tests/benchmarks/qstringlist/main.cpp +++ b/tests/benchmarks/qstringlist/main.cpp @@ -54,17 +54,21 @@ private slots: void join() const; void join_data() const; - void split() const; + void split_qlist_qbytearray() const; + void split_qlist_qbytearray_data() const { return split_data(); } + void split_data() const; + void split_qlist_qstring() const; + void split_qlist_qstring_data() const { return split_data(); } - void split_std() const; - void split_std_data() const { return split_data(); } + void split_stdvector_stdstring() const; + void split_stdvector_stdstring_data() const { return split_data(); } - void split_stdw() const; - void split_stdw_data() const { return split_data(); } + void split_stdvector_stdwstring() const; + void split_stdvector_stdwstring_data() const { return split_data(); } - void split_ba() const; - void split_ba_data() const { return split_data(); } + void split_stdlist_stdstring() const; + void split_stdlist_stdstring_data() const { return split_data(); } private: static QStringList populateList(const int count, const QString &unit); @@ -125,27 +129,39 @@ void tst_QStringList::join_data() const << QString(); } -void tst_QStringList::split() const +void tst_QStringList::split_data() const +{ + QTest::addColumn<QString>("input"); + QString unit = QLatin1String("unit") + QString(100, QLatin1Char('s')); + //QTest::newRow("") << populateString(10, unit); + QTest::newRow("") << populateString(100, unit); + //QTest::newRow("") << populateString(100, unit); + //QTest::newRow("") << populateString(1000, unit); + //QTest::newRow("") << populateString(10000, unit); +} + +void tst_QStringList::split_qlist_qbytearray() const { QFETCH(QString, input); - const QChar splitChar = ':'; + const char splitChar = ':'; + QByteArray ba = input.toLatin1(); QBENCHMARK { - input.split(splitChar); + ba.split(splitChar); } } -void tst_QStringList::split_data() const +void tst_QStringList::split_qlist_qstring() const { - QTest::addColumn<QString>("input"); - QString unit = QLatin1String("unit"); - QTest::newRow("") << populateString(10, unit); - QTest::newRow("") << populateString(100, unit); - QTest::newRow("") << populateString(1000, unit); - QTest::newRow("") << populateString(10000, unit); + QFETCH(QString, input); + const QChar splitChar = ':'; + + QBENCHMARK { + input.split(splitChar); + } } -void tst_QStringList::split_std() const +void tst_QStringList::split_stdvector_stdstring() const { QFETCH(QString, input); const char split_char = ':'; @@ -161,7 +177,7 @@ void tst_QStringList::split_std() const } } -void tst_QStringList::split_stdw() const +void tst_QStringList::split_stdvector_stdwstring() const { QFETCH(QString, input); const wchar_t split_char = ':'; @@ -177,14 +193,19 @@ void tst_QStringList::split_stdw() const } } -void tst_QStringList::split_ba() const +void tst_QStringList::split_stdlist_stdstring() const { QFETCH(QString, input); - const char splitChar = ':'; - QByteArray ba = input.toLatin1(); + const char split_char = ':'; + std::string stdinput = input.toStdString(); QBENCHMARK { - ba.split(splitChar); + std::istringstream split(stdinput); + std::list<std::string> token; + for (std::string each; + std::getline(split, each, split_char); + token.push_back(each)) + ; } } diff --git a/tests/benchmarks/qstringlist/qstringlist.pro b/tests/benchmarks/qstringlist/qstringlist.pro index f9ebd59..86c1508 100644 --- a/tests/benchmarks/qstringlist/qstringlist.pro +++ b/tests/benchmarks/qstringlist/qstringlist.pro @@ -1,4 +1,6 @@ load(qttest_p4) TARGET = tst_qstringlist +CONFIG -= debug +CONFIG += release QT -= gui SOURCES += main.cpp |