diff options
Diffstat (limited to 'tests/benchmarks/qstringbuilder/main.cpp')
-rw-r--r-- | tests/benchmarks/qstringbuilder/main.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp index 9b2bc99a7c..ba5cfe0a76 100644 --- a/tests/benchmarks/qstringbuilder/main.cpp +++ b/tests/benchmarks/qstringbuilder/main.cpp @@ -16,69 +16,91 @@ public: private slots: // QStringBuilder based - void builderbased_l1literal_l1literal(); - void builderbased_l1literal_l1literal_l1literal(); - void builderbased_l1literal_l1literal_l1literal_l1literal(); + void b_separator() { qDebug() << "\n------- QStringBuilder based ----------"; } + void b_2_l1literal(); + void b_3_l1literal(); + void b_4_l1literal(); + void b_string_4_char(); // QString based for comparison - void stringbased_l1string_l1string(); - void stringbased_l1string_l1string_l1string(); - void stringbased_l1string_l1string_l1string_l1string(); + void s_separator() { qDebug() << "\n-------- QString based ---------"; } + void s_2_l1string(); + void s_3_l1string(); + void s_4_l1string(); + void s_string_4_char(); private: const QLatin1Literal l1literal; const QLatin1String l1string; + const QString string; + const char achar; }; tst_qstringbuilder::tst_qstringbuilder() - : l1literal("some literal"), l1string("some literal") + : l1literal("some literal"), + l1string("some literal"), + string(l1string), + achar('c') {} -void tst_qstringbuilder::builderbased_l1literal_l1literal() +void tst_qstringbuilder::b_2_l1literal() { QString result; QBENCHMARK { result = l1literal % l1literal; } QCOMPARE(result, l1string + l1string); } -void tst_qstringbuilder::builderbased_l1literal_l1literal_l1literal() +void tst_qstringbuilder::b_3_l1literal() { QString result; QBENCHMARK { result = l1literal % l1literal % l1literal; } QCOMPARE(result, l1string + l1string + l1string); } -void tst_qstringbuilder::builderbased_l1literal_l1literal_l1literal_l1literal() +void tst_qstringbuilder::b_4_l1literal() { QString result; QBENCHMARK { result = l1literal % l1literal % l1literal % l1literal; } QCOMPARE(result, l1string + l1string + l1string + l1string); } +void tst_qstringbuilder::b_string_4_char() +{ + QString result; + QBENCHMARK { result = string + achar + achar + achar; } + QCOMPARE(result, QString(string % achar % achar % achar)); +} -void tst_qstringbuilder::stringbased_l1string_l1string() +void tst_qstringbuilder::s_2_l1string() { QString result; QBENCHMARK { result = l1string + l1string; } QCOMPARE(result, QString(l1literal % l1literal)); } -void tst_qstringbuilder::stringbased_l1string_l1string_l1string() +void tst_qstringbuilder::s_3_l1string() { QString result; QBENCHMARK { result = l1string + l1string + l1string; } QCOMPARE(result, QString(l1literal % l1literal % l1literal)); } -void tst_qstringbuilder::stringbased_l1string_l1string_l1string_l1string() +void tst_qstringbuilder::s_4_l1string() { QString result; QBENCHMARK { result = l1string + l1string + l1string + l1string; } QCOMPARE(result, QString(l1literal % l1literal % l1literal % l1literal)); } +void tst_qstringbuilder::s_string_4_char() +{ + QString result; + QBENCHMARK { result = string + achar + achar + achar; } + QCOMPARE(result, QString(string % achar % achar % achar)); +} + QTEST_MAIN(tst_qstringbuilder) #include "main.moc" |