Add QTZ::displayName() benchmarks
Task-number: QTBUG-115158 Pick-to: 6.7 6.5 6.2 5.15 Change-Id: I7465a19f6003cfae7507d798fadeab22bf1b118d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 01acb888e0f9f06cac07d69d8c934eac9d32daf3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c8d7f1a5ec
commit
6cc95e1d92
@ -20,6 +20,8 @@ private Q_SLOTS:
|
||||
void systemTimeZone();
|
||||
void zoneByName_data();
|
||||
void zoneByName();
|
||||
void displayName_data();
|
||||
void displayName();
|
||||
void transitionList_data();
|
||||
void transitionList();
|
||||
void transitionsForward_data() { transitionList_data(); }
|
||||
@ -89,6 +91,72 @@ void tst_QTimeZone::zoneByName()
|
||||
Q_UNUSED(zone);
|
||||
}
|
||||
|
||||
void tst_QTimeZone::displayName_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("ianaId");
|
||||
QTest::addColumn<QDateTime>("when");
|
||||
QTest::addColumn<QLocale>("where");
|
||||
QTest::addColumn<QTimeZone::NameType>("type");
|
||||
|
||||
const QLocale sys = QLocale::system();
|
||||
const QLocale locs[] = {
|
||||
QLocale::c(),
|
||||
// System locale and its CLDR-equivalent:
|
||||
sys, QLocale(sys.language(), sys.script(), sys.territory()),
|
||||
// An assortment of CLDR ones:
|
||||
QLocale(QLocale::Arabic, QLocale::Lebanon),
|
||||
QLocale(QLocale::Chinese, QLocale::China),
|
||||
QLocale(QLocale::English, QLocale::UnitedStates),
|
||||
QLocale(QLocale::French, QLocale::France),
|
||||
QLocale(QLocale::Finnish, QLocale::Finland),
|
||||
QLocale(QLocale::German, QLocale::Germany),
|
||||
QLocale(QLocale::NorwegianBokmal, QLocale::Norway),
|
||||
QLocale(QLocale::Ukrainian, QLocale::Ukraine),
|
||||
};
|
||||
const QByteArray locName[] = { "C", "system", "CLDR-sys" };
|
||||
const QDateTime times[] = {
|
||||
QDate(1970, 1, 1).startOfDay(QTimeZone::UTC),
|
||||
QDate(2000, 2, 29).startOfDay(QTimeZone::UTC),
|
||||
QDate(2020, 4, 30).startOfDay(QTimeZone::UTC),
|
||||
};
|
||||
|
||||
const auto names = enoughZones();
|
||||
for (const auto &name : names) {
|
||||
for (const auto &when : times) {
|
||||
qsizetype locIndex = 0;
|
||||
for (const auto &where : locs) {
|
||||
const QByteArray dt = when.toString(Qt::ISODate).toUtf8();
|
||||
const QByteArray loc =
|
||||
locIndex < std::size(locName) ? locName[locIndex] : where.bcp47Name().toUtf8();
|
||||
QTest::addRow("%s@%s/%s:default", name.data(), dt.data(), loc.data())
|
||||
<< name << when << where << QTimeZone::DefaultName;
|
||||
QTest::addRow("%s@%s/%s:long", name.data(), dt.data(), loc.data())
|
||||
<< name << when << where << QTimeZone::LongName;
|
||||
QTest::addRow("%s@%s/%s:short", name.data(), dt.data(), loc.data())
|
||||
<< name << when << where << QTimeZone::ShortName;
|
||||
QTest::addRow("%s@%s/%s:offset", name.data(), dt.data(), loc.data())
|
||||
<< name << when << where << QTimeZone::OffsetName;
|
||||
++locIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTimeZone::displayName()
|
||||
{
|
||||
QFETCH(const QByteArray, ianaId);
|
||||
QFETCH(const QDateTime, when);
|
||||
QFETCH(const QLocale, where);
|
||||
QFETCH(const QTimeZone::NameType, type);
|
||||
|
||||
const QTimeZone zone(ianaId);
|
||||
QString name;
|
||||
QBENCHMARK {
|
||||
name = zone.displayName(when, type, where);
|
||||
}
|
||||
Q_UNUSED(name);
|
||||
}
|
||||
|
||||
void tst_QTimeZone::transitionList_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("name");
|
||||
|
Loading…
x
Reference in New Issue
Block a user