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. Pick-to: 6.6 6.5 6.2 5.15 Task-number: QTBUG-116859 Change-Id: I1da93885e938045322ba8337df5e4e96985f892f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a86fda6423
commit
e1dcc858b2
@ -49,7 +49,12 @@ private:
|
||||
|
||||
QStringList tst_QStringList::populateList(const int count, const QString &unit)
|
||||
{
|
||||
return QStringList(count, unit);
|
||||
QStringList retval;
|
||||
retval.reserve(count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
retval.append(unit + QString::number(i));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
QString tst_QStringList::populateString(const int count, const QString &unit)
|
||||
@ -79,20 +84,20 @@ 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("")
|
||||
<< populateList(10000, QLatin1String("unit"))
|
||||
QTest::newRow("10000")
|
||||
<< populateList(10'000, QLatin1String("unit"))
|
||||
<< QString();
|
||||
|
||||
QTest::newRow("")
|
||||
<< populateList(100000, QLatin1String("unit"))
|
||||
QTest::newRow("100000")
|
||||
<< populateList(100'000, QLatin1String("unit"))
|
||||
<< QString();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user