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 <thiago.macieira@intel.com>
(cherry picked from commit e1dcc858b2a0ac2b359cdbf7e07e70c1237daef0)
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit e1fe8963a78fd91a1307b3c302c69cc74136aee7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ea5035bfb4e69ffd3792a093128e418b38d07ad1)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 0d3585447467f1e437827e6d63ff69ee4114a9d5)
This commit is contained in:
Ahmad Samir 2023-04-08 13:38:49 +02:00 committed by Marc Mutz
parent 165daa88c1
commit ae62bd02f1

View File

@ -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<QStringList>("input");
QTest::addColumn<QString>("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();
}