From ae62bd02f1c92350a8838f1b1d1ad3e8ce9db924 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 8 Apr 2023 13:38:49 +0200 Subject: [PATCH] QStringList: improve benchmark code Make the strings in the stringlist-to-be-joined unique, which matches actual use-cases better than joining a list of identical strings, especially with QString's implicit sharing, if it's copies of the same QString, it's sharing the underlying data. Manual conflict resolutions: - Removed C++14 digit separators to restore C++11 compatibility Task-number: QTBUG-116859 Change-Id: I1da93885e938045322ba8337df5e4e96985f892f Reviewed-by: Thiago Macieira (cherry picked from commit e1dcc858b2a0ac2b359cdbf7e07e70c1237daef0) Reviewed-by: Marc Mutz (cherry picked from commit e1fe8963a78fd91a1307b3c302c69cc74136aee7) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit ea5035bfb4e69ffd3792a093128e418b38d07ad1) Reviewed-by: Volker Hilsheimer (cherry picked from commit 0d3585447467f1e437827e6d63ff69ee4114a9d5) --- tests/benchmarks/corelib/text/qstringlist/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/benchmarks/corelib/text/qstringlist/main.cpp b/tests/benchmarks/corelib/text/qstringlist/main.cpp index 9f184d0cf58..0d41e934415 100644 --- a/tests/benchmarks/corelib/text/qstringlist/main.cpp +++ b/tests/benchmarks/corelib/text/qstringlist/main.cpp @@ -68,9 +68,9 @@ private: QStringList tst_QStringList::populateList(const int count, const QString &unit) { QStringList retval; - + retval.reserve(count); for (int i = 0; i < count; ++i) - retval.append(unit); + retval.append(unit + QString::number(i)); return retval; } @@ -102,19 +102,19 @@ void tst_QStringList::join_data() const QTest::addColumn("input"); QTest::addColumn("separator"); - QTest::newRow("") + QTest::newRow("100") << populateList(100, QLatin1String("unit")) << QString(); - QTest::newRow("") + QTest::newRow("1000") << populateList(1000, QLatin1String("unit")) << QString(); - QTest::newRow("") + QTest::newRow("10000") << populateList(10000, QLatin1String("unit")) << QString(); - QTest::newRow("") + QTest::newRow("100000") << populateList(100000, QLatin1String("unit")) << QString(); }