summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib/time/qtimezone
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/corelib/time/qtimezone')
-rw-r--r--tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp48
2 files changed, 31 insertions, 22 deletions
diff --git a/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt b/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt
index 99d8b7f044..f80b64be2d 100644
--- a/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt
+++ b/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qtimezone Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qtimezone
SOURCES
tst_bench_qtimezone.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp
index 8e8ea4b55c..db8b910d98 100644
--- a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp
+++ b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp
@@ -1,6 +1,7 @@
+// Copyright (C) 2022 The Qt Company Ltd.
// Copyright (C) 2019 Crimson AS <info@crimson.no>
// Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTimeZone>
#include <QTest>
@@ -14,6 +15,7 @@ class tst_QTimeZone : public QObject
Q_OBJECT
private Q_SLOTS:
+#if QT_CONFIG(timezone)
void isTimeZoneIdAvailable();
void systemTimeZone();
void zoneByName_data();
@@ -24,31 +26,35 @@ private Q_SLOTS:
void transitionsForward();
void transitionsReverse_data() { transitionList_data(); }
void transitionsReverse();
+#endif
};
static QList<QByteArray> enoughZones()
{
#ifdef EXHAUSTIVE
- auto available = QTimeZone::availableTimeZoneIds();
- QList<QByteArray> result;
- result.reserve(available.size() + 1);
- for (conat auto &name : available)
- result << name;
+ QList<QByteArray> result = QTimeZone::availableTimeZoneIds();
#else
- QList<QByteArray> result { QByteArray("UTC"),
- // Those named overtly in tst_QDateTime:
- QByteArray("Europe/Oslo"), QByteArray("America/Vancouver"),
- QByteArray("Europe/Berlin"), QByteArray("America/Sao_Paulo"),
- QByteArray("Pacific/Auckland"), QByteArray("Australia/Eucla"),
- QByteArray("Asia/Kathmandu"), QByteArray("Pacific/Kiritimati"),
- QByteArray("Pacific/Apia"), QByteArray("UTC+12:00"),
- QByteArray("Australia/Sydney"), QByteArray("Asia/Singapore"),
- QByteArray("Australia/Brisbane") };
+ QList<QByteArray> result {
+ QByteArray("UTC"),
+ // Those named overtly in tst_QDateTime - special cases first:
+ QByteArray("UTC-02:00"), QByteArray("UTC+02:00"), QByteArray("UTC+12:00"),
+ QByteArray("Etc/GMT+3"), QByteArray("GMT-2"), QByteArray("GMT"),
+ // ... then ordinary names in alphabetic order:
+ QByteArray("America/New_York"), QByteArray("America/Sao_Paulo"),
+ QByteArray("America/Vancouver"),
+ QByteArray("Asia/Kathmandu"), QByteArray("Asia/Singapore"),
+ QByteArray("Australia/Brisbane"), QByteArray("Australia/Eucla"),
+ QByteArray("Australia/Sydney"),
+ QByteArray("Europe/Berlin"), QByteArray("Europe/Helsinki"),
+ QByteArray("Europe/Rome"), QByteArray("Europe/Oslo"),
+ QByteArray("Pacific/Apia"), QByteArray("Pacific/Auckland"),
+ QByteArray("Pacific/Kiritimati")
+ };
#endif
result << QByteArray("Vulcan/ShiKahr"); // invalid: also worth testing
return result;
}
-
+#if QT_CONFIG(timezone)
void tst_QTimeZone::isTimeZoneIdAvailable()
{
const QList<QByteArray> available = QTimeZone::availableTimeZoneIds();
@@ -64,7 +70,6 @@ void tst_QTimeZone::systemTimeZone()
QTimeZone::systemTimeZone();
}
}
-
void tst_QTimeZone::zoneByName_data()
{
QTest::addColumn<QByteArray>("name");
@@ -101,9 +106,9 @@ void tst_QTimeZone::transitionList()
{
QFETCH(QByteArray, name);
const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name);
- const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date
+ const QDateTime early = QDate(1625, 6, 8).startOfDay(QTimeZone::UTC); // Cassini's birth date
const QDateTime late // End of 32-bit signed time_t
- = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), Qt::UTC);
+ = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), QTimeZone::UTC);
QTimeZone::OffsetDataList seq;
QBENCHMARK {
seq = zone.transitions(early, late);
@@ -115,7 +120,7 @@ void tst_QTimeZone::transitionsForward()
{
QFETCH(QByteArray, name);
const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name);
- const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date
+ const QDateTime early = QDate(1625, 6, 8).startOfDay(QTimeZone::UTC); // Cassini's birth date
QBENCHMARK {
QTimeZone::OffsetData tran = zone.nextTransition(early);
while (tran.atUtc.isValid())
@@ -128,13 +133,14 @@ void tst_QTimeZone::transitionsReverse()
QFETCH(QByteArray, name);
const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name);
const QDateTime late // End of 32-bit signed time_t
- = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), Qt::UTC);
+ = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), QTimeZone::UTC);
QBENCHMARK {
QTimeZone::OffsetData tran = zone.previousTransition(late);
while (tran.atUtc.isValid())
tran = zone.previousTransition(tran.atUtc);
}
}
+#endif
QTEST_MAIN(tst_QTimeZone)