From 5652d33f973a03b93c9b5ce9e49db8cf0430b675 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 11:54:31 +0200 Subject: Bump version to Qt 6 Needed to disable QT_NO_UNSHARABLE_CONTAINERS, as this triggers asserts. QMetaType also has some Qt 6 specific code disabled to get things to compile. Fix various details in autotests to accommodate for the changes with Qt 6. Add a workaround for black lists on macos, where QSysInfo::productType() now returns 'macos' and not 'osx' anymore. Change-Id: Ie26afb12a2aac36521472715934a7e34639ea4d0 Reviewed-by: Simon Hausmann --- tests/benchmarks/corelib/tools/qvector/outofline.cpp | 2 +- .../network/access/qfile_vs_qnetworkaccessmanager/main.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/benchmarks') diff --git a/tests/benchmarks/corelib/tools/qvector/outofline.cpp b/tests/benchmarks/corelib/tools/qvector/outofline.cpp index 76a4edaa10..7182a43008 100644 --- a/tests/benchmarks/corelib/tools/qvector/outofline.cpp +++ b/tests/benchmarks/corelib/tools/qvector/outofline.cpp @@ -54,7 +54,7 @@ QVector mixedvector_fill_and_return_helper() std::vector v(N); for (int i = 0; i != N; ++i) v[i] = i; - return QVector::fromStdVector(v); + return QVector(v.begin(), v.end()); } diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp index 46bb1791b4..1f3f38eaaf 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp @@ -105,7 +105,7 @@ void qfile_vs_qnetworkaccessmanager::qnamFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } @@ -138,7 +138,7 @@ void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } @@ -167,7 +167,7 @@ void qfile_vs_qnetworkaccessmanager::qfileFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } -- cgit v1.2.3 From 548513a4bd050d3df0a85fed6e2d1a00ce06d2ab Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 27 May 2019 17:47:22 +0200 Subject: Separate out the time, zone, date code from corelib/tools/ We'll be adding calendar code here as well, and tools/ was getting rather crowded, so it looks like time to move out a reasonably coherent sub-bundle of it all. Change-Id: I7e8030f38c31aa307f519dd918a43fc44baa6aa1 Reviewed-by: Lars Knoll --- tests/benchmarks/corelib/corelib.pro | 1 + tests/benchmarks/corelib/time/qdate/qdate.pro | 4 + .../corelib/time/qdate/tst_bench_qdate.cpp | 53 ++ tests/benchmarks/corelib/time/qdatetime/main.cpp | 601 +++++++++++++++++++++ .../corelib/time/qdatetime/qdatetime.pro | 4 + tests/benchmarks/corelib/time/qtimezone/main.cpp | 52 ++ .../corelib/time/qtimezone/qtimezone.pro | 4 + tests/benchmarks/corelib/time/time.pro | 5 + tests/benchmarks/corelib/tools/qdate/qdate.pro | 4 - .../corelib/tools/qdate/tst_bench_qdate.cpp | 53 -- tests/benchmarks/corelib/tools/qdatetime/main.cpp | 601 --------------------- .../corelib/tools/qdatetime/qdatetime.pro | 4 - tests/benchmarks/corelib/tools/qtimezone/main.cpp | 52 -- .../corelib/tools/qtimezone/qtimezone.pro | 4 - tests/benchmarks/corelib/tools/tools.pro | 2 - 15 files changed, 724 insertions(+), 720 deletions(-) create mode 100644 tests/benchmarks/corelib/time/qdate/qdate.pro create mode 100644 tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp create mode 100644 tests/benchmarks/corelib/time/qdatetime/main.cpp create mode 100644 tests/benchmarks/corelib/time/qdatetime/qdatetime.pro create mode 100644 tests/benchmarks/corelib/time/qtimezone/main.cpp create mode 100644 tests/benchmarks/corelib/time/qtimezone/qtimezone.pro create mode 100644 tests/benchmarks/corelib/time/time.pro delete mode 100644 tests/benchmarks/corelib/tools/qdate/qdate.pro delete mode 100644 tests/benchmarks/corelib/tools/qdate/tst_bench_qdate.cpp delete mode 100644 tests/benchmarks/corelib/tools/qdatetime/main.cpp delete mode 100644 tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro delete mode 100644 tests/benchmarks/corelib/tools/qtimezone/main.cpp delete mode 100644 tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro (limited to 'tests/benchmarks') diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro index b5781ad49e..99af4c138f 100644 --- a/tests/benchmarks/corelib/corelib.pro +++ b/tests/benchmarks/corelib/corelib.pro @@ -5,6 +5,7 @@ SUBDIRS = \ mimetypes \ kernel \ thread \ + time \ tools \ codecs \ plugin diff --git a/tests/benchmarks/corelib/time/qdate/qdate.pro b/tests/benchmarks/corelib/time/qdate/qdate.pro new file mode 100644 index 0000000000..a655917135 --- /dev/null +++ b/tests/benchmarks/corelib/time/qdate/qdate.pro @@ -0,0 +1,4 @@ +TARGET = tst_bench_qdate +QT = core testlib + +SOURCES += tst_bench_qdate.cpp diff --git a/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp new file mode 100644 index 0000000000..399ac44065 --- /dev/null +++ b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class tst_QDate : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void monthLengths(); +}; + +void tst_QDate::monthLengths() +{ + QBENCHMARK { + for (int year = 1900; year <= 2100; year++) { + bool check = true; + for (int month = 1; month <= 12; month++) + check &= QDate::isValid(year, month, QDate(year, month, 1).daysInMonth()); + Q_UNUSED(check); + } + } +} + +QTEST_MAIN(tst_QDate) +#include "tst_bench_qdate.moc" diff --git a/tests/benchmarks/corelib/time/qdatetime/main.cpp b/tests/benchmarks/corelib/time/qdatetime/main.cpp new file mode 100644 index 0000000000..b693400376 --- /dev/null +++ b/tests/benchmarks/corelib/time/qdatetime/main.cpp @@ -0,0 +1,601 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_QDateTime : public QObject +{ + Q_OBJECT + + enum : qint64 + { + SECS_PER_DAY = 86400, + MSECS_PER_DAY = 86400000, + JULIAN_DAY_1950 = 2433283, + JULIAN_DAY_1960 = 2436935, + JULIAN_DAY_2010 = 2455198, + JULIAN_DAY_2011 = 2455563, + JULIAN_DAY_2020 = 2458850, + JULIAN_DAY_2050 = 2469808, + JULIAN_DAY_2060 = 2473460 + }; + +private Q_SLOTS: + void create(); + void isNull(); + void isValid(); + void date(); + void time(); + void timeSpec(); + void offsetFromUtc(); + void timeZoneAbbreviation(); + void toMSecsSinceEpoch(); + void toMSecsSinceEpoch1950(); + void toMSecsSinceEpoch2050(); + void toMSecsSinceEpochTz(); + void toMSecsSinceEpoch1950Tz(); + void toMSecsSinceEpoch2050Tz(); + void setDate(); + void setTime(); + void setTimeSpec(); + void setOffsetFromUtc(); + void setMSecsSinceEpoch(); + void setMSecsSinceEpochTz(); + void toString(); + void toStringTextFormat(); + void toStringIsoFormat(); + void addDays(); + void addDaysTz(); + void addMSecs(); + void addMSecsTz(); + void toTimeSpec(); + void toOffsetFromUtc(); + void daysTo(); + void msecsTo(); + void equivalent(); + void equivalentUtc(); + void lessThan(); + void lessThanUtc(); + void currentDateTime(); + void currentDate(); + void currentTime(); + void currentDateTimeUtc(); + void currentMSecsSinceEpoch(); + void fromString(); + void fromStringText(); + void fromStringIso(); + void fromMSecsSinceEpoch(); + void fromMSecsSinceEpochUtc(); + void fromMSecsSinceEpochTz(); +}; + +void tst_QDateTime::create() +{ + QBENCHMARK { + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) { + QDateTime test(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)); + Q_UNUSED(test) + } + } +} + +void tst_QDateTime::isNull() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.isNull(); + } +} + +void tst_QDateTime::isValid() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.isValid(); + } +} + +void tst_QDateTime::date() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.date(); + } +} + +void tst_QDateTime::time() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.time(); + } +} + +void tst_QDateTime::timeSpec() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.timeSpec(); + } +} + +void tst_QDateTime::offsetFromUtc() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.offsetFromUtc(); + } +} + +void tst_QDateTime::timeZoneAbbreviation() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.timeZoneAbbreviation(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch1950() +{ + QList list; + for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch2050() +{ + QList list; + for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpochTz() +{ + QTimeZone cet = QTimeZone("Europe/Oslo"); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + QBENCHMARK { + foreach (const QDateTime &test, list) + qint64 result = test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch1950Tz() +{ + QTimeZone cet = QTimeZone("Europe/Oslo"); + QList list; + for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + QBENCHMARK { + foreach (const QDateTime &test, list) + qint64 result = test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::toMSecsSinceEpoch2050Tz() +{ + QTimeZone cet = QTimeZone("Europe/Oslo"); + QList list; + for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + QBENCHMARK { + foreach (const QDateTime &test, list) + qint64 result = test.toMSecsSinceEpoch(); + } +} + +void tst_QDateTime::setDate() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (QDateTime test, list) + test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010)); + } +} + +void tst_QDateTime::setTime() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (QDateTime test, list) + test.setTime(QTime(12, 0, 0)); + } +} + +void tst_QDateTime::setTimeSpec() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (QDateTime test, list) + test.setTimeSpec(Qt::UTC); + } +} + +void tst_QDateTime::setOffsetFromUtc() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (QDateTime test, list) + test.setOffsetFromUtc(3600); + } +} + +void tst_QDateTime::setMSecsSinceEpoch() +{ + qint64 msecs = qint64(JULIAN_DAY_2010 + 180) * MSECS_PER_DAY; + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (QDateTime test, list) + test.setMSecsSinceEpoch(msecs); + } +} + +void tst_QDateTime::setMSecsSinceEpochTz() +{ + QTimeZone cet = QTimeZone("Europe/Oslo"); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + QBENCHMARK { + foreach (QDateTime test, list) + test.setMSecsSinceEpoch((JULIAN_DAY_2010 + 180) * MSECS_PER_DAY); + } +} + +void tst_QDateTime::toString() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t")); + } +} + +void tst_QDateTime::toStringTextFormat() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toString(Qt::TextDate); + } +} + +void tst_QDateTime::toStringIsoFormat() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toString(Qt::ISODate); + } +} + +void tst_QDateTime::addDays() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.addDays(1); + } +} + +void tst_QDateTime::addDaysTz() +{ + QTimeZone cet = QTimeZone("Europe/Oslo"); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + QBENCHMARK { + foreach (const QDateTime &test, list) + QDateTime result = test.addDays(1); + } +} + +void tst_QDateTime::addMSecs() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.addMSecs(1); + } +} + +void tst_QDateTime::addMSecsTz() +{ + QTimeZone cet = QTimeZone("Europe/Oslo"); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + QBENCHMARK { + foreach (const QDateTime &test, list) + QDateTime result = test.addMSecs(1); + } +} + +void tst_QDateTime::toTimeSpec() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toTimeSpec(Qt::UTC); + } +} + +void tst_QDateTime::toOffsetFromUtc() +{ + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.toOffsetFromUtc(3600); + } +} + +void tst_QDateTime::daysTo() +{ + QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.daysTo(other); + } +} + +void tst_QDateTime::msecsTo() +{ + QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + test.msecsTo(other); + } +} + +void tst_QDateTime::equivalent() +{ + bool result; + QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + result = (test == other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::equivalentUtc() +{ + bool result = false; + QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + result = (test == other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::lessThan() +{ + bool result = false; + QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + result = (test < other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::lessThanUtc() +{ + bool result = false; + QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC); + QList list; + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + QBENCHMARK { + foreach (const QDateTime &test, list) + result = (test < other); + } + Q_UNUSED(result) +} + +void tst_QDateTime::currentDateTime() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::currentDateTime(); + } +} + +void tst_QDateTime::currentDate() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDate::currentDate(); + } +} + +void tst_QDateTime::currentTime() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QTime::currentTime(); + } +} + +void tst_QDateTime::currentDateTimeUtc() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::currentDateTimeUtc(); + } +} + +void tst_QDateTime::currentMSecsSinceEpoch() +{ + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::currentMSecsSinceEpoch(); + } +} + +void tst_QDateTime::fromString() +{ + QString format = "yyyy-MM-dd hh:mm:ss.zzz"; + QString input = "2010-01-01 13:12:11.999"; + QVERIFY(QDateTime::fromString(input, format).isValid()); + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::fromString(input, format); + } +} + +void tst_QDateTime::fromStringText() +{ + QString input = "Wed Jan 2 01:02:03.000 2013 GMT"; + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::fromString(input, Qt::TextDate); + } +} + +void tst_QDateTime::fromStringIso() +{ + QString input = "2010-01-01T13:28:34.999Z"; + QBENCHMARK { + for (int i = 0; i < 1000; ++i) + QDateTime::fromString(input, Qt::ISODate); + } +} + +void tst_QDateTime::fromMSecsSinceEpoch() +{ + QBENCHMARK { + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime); + } +} + +void tst_QDateTime::fromMSecsSinceEpochUtc() +{ + QBENCHMARK { + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC); + } +} + +void tst_QDateTime::fromMSecsSinceEpochTz() +{ + QTimeZone cet = QTimeZone("Europe/Oslo"); + QBENCHMARK { + for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) + QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet); + } +} + +QTEST_MAIN(tst_QDateTime) + +#include "main.moc" diff --git a/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro new file mode 100644 index 0000000000..a85e7346c6 --- /dev/null +++ b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro @@ -0,0 +1,4 @@ +TARGET = tst_bench_qdatetime +QT = core testlib + +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/time/qtimezone/main.cpp b/tests/benchmarks/corelib/time/qtimezone/main.cpp new file mode 100644 index 0000000000..65455a7261 --- /dev/null +++ b/tests/benchmarks/corelib/time/qtimezone/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_QTimeZone : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void isTimeZoneIdAvailable(); +}; + +void tst_QTimeZone::isTimeZoneIdAvailable() +{ + const QList available = QTimeZone::availableTimeZoneIds(); + QBENCHMARK { + for (const QByteArray &id : available) + QVERIFY(QTimeZone::isTimeZoneIdAvailable(id)); + } +} + +QTEST_MAIN(tst_QTimeZone) + +#include "main.moc" diff --git a/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro new file mode 100644 index 0000000000..d0531b568b --- /dev/null +++ b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro @@ -0,0 +1,4 @@ +TARGET = tst_bench_qtimezone +QT = core testlib + +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/time/time.pro b/tests/benchmarks/corelib/time/time.pro new file mode 100644 index 0000000000..b5184845d9 --- /dev/null +++ b/tests/benchmarks/corelib/time/time.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qdate \ + qdatetime \ + qtimezone diff --git a/tests/benchmarks/corelib/tools/qdate/qdate.pro b/tests/benchmarks/corelib/tools/qdate/qdate.pro deleted file mode 100644 index a655917135..0000000000 --- a/tests/benchmarks/corelib/tools/qdate/qdate.pro +++ /dev/null @@ -1,4 +0,0 @@ -TARGET = tst_bench_qdate -QT = core testlib - -SOURCES += tst_bench_qdate.cpp diff --git a/tests/benchmarks/corelib/tools/qdate/tst_bench_qdate.cpp b/tests/benchmarks/corelib/tools/qdate/tst_bench_qdate.cpp deleted file mode 100644 index 399ac44065..0000000000 --- a/tests/benchmarks/corelib/tools/qdate/tst_bench_qdate.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -class tst_QDate : public QObject -{ - Q_OBJECT - -private Q_SLOTS: - void monthLengths(); -}; - -void tst_QDate::monthLengths() -{ - QBENCHMARK { - for (int year = 1900; year <= 2100; year++) { - bool check = true; - for (int month = 1; month <= 12; month++) - check &= QDate::isValid(year, month, QDate(year, month, 1).daysInMonth()); - Q_UNUSED(check); - } - } -} - -QTEST_MAIN(tst_QDate) -#include "tst_bench_qdate.moc" diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp deleted file mode 100644 index b693400376..0000000000 --- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp +++ /dev/null @@ -1,601 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -class tst_QDateTime : public QObject -{ - Q_OBJECT - - enum : qint64 - { - SECS_PER_DAY = 86400, - MSECS_PER_DAY = 86400000, - JULIAN_DAY_1950 = 2433283, - JULIAN_DAY_1960 = 2436935, - JULIAN_DAY_2010 = 2455198, - JULIAN_DAY_2011 = 2455563, - JULIAN_DAY_2020 = 2458850, - JULIAN_DAY_2050 = 2469808, - JULIAN_DAY_2060 = 2473460 - }; - -private Q_SLOTS: - void create(); - void isNull(); - void isValid(); - void date(); - void time(); - void timeSpec(); - void offsetFromUtc(); - void timeZoneAbbreviation(); - void toMSecsSinceEpoch(); - void toMSecsSinceEpoch1950(); - void toMSecsSinceEpoch2050(); - void toMSecsSinceEpochTz(); - void toMSecsSinceEpoch1950Tz(); - void toMSecsSinceEpoch2050Tz(); - void setDate(); - void setTime(); - void setTimeSpec(); - void setOffsetFromUtc(); - void setMSecsSinceEpoch(); - void setMSecsSinceEpochTz(); - void toString(); - void toStringTextFormat(); - void toStringIsoFormat(); - void addDays(); - void addDaysTz(); - void addMSecs(); - void addMSecsTz(); - void toTimeSpec(); - void toOffsetFromUtc(); - void daysTo(); - void msecsTo(); - void equivalent(); - void equivalentUtc(); - void lessThan(); - void lessThanUtc(); - void currentDateTime(); - void currentDate(); - void currentTime(); - void currentDateTimeUtc(); - void currentMSecsSinceEpoch(); - void fromString(); - void fromStringText(); - void fromStringIso(); - void fromMSecsSinceEpoch(); - void fromMSecsSinceEpochUtc(); - void fromMSecsSinceEpochTz(); -}; - -void tst_QDateTime::create() -{ - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) { - QDateTime test(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)); - Q_UNUSED(test) - } - } -} - -void tst_QDateTime::isNull() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.isNull(); - } -} - -void tst_QDateTime::isValid() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.isValid(); - } -} - -void tst_QDateTime::date() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.date(); - } -} - -void tst_QDateTime::time() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.time(); - } -} - -void tst_QDateTime::timeSpec() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.timeSpec(); - } -} - -void tst_QDateTime::offsetFromUtc() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.offsetFromUtc(); - } -} - -void tst_QDateTime::timeZoneAbbreviation() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.timeZoneAbbreviation(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch1950() -{ - QList list; - for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch2050() -{ - QList list; - for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpochTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - qint64 result = test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch1950Tz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList list; - for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - qint64 result = test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::toMSecsSinceEpoch2050Tz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList list; - for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - qint64 result = test.toMSecsSinceEpoch(); - } -} - -void tst_QDateTime::setDate() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010)); - } -} - -void tst_QDateTime::setTime() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setTime(QTime(12, 0, 0)); - } -} - -void tst_QDateTime::setTimeSpec() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setTimeSpec(Qt::UTC); - } -} - -void tst_QDateTime::setOffsetFromUtc() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setOffsetFromUtc(3600); - } -} - -void tst_QDateTime::setMSecsSinceEpoch() -{ - qint64 msecs = qint64(JULIAN_DAY_2010 + 180) * MSECS_PER_DAY; - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (QDateTime test, list) - test.setMSecsSinceEpoch(msecs); - } -} - -void tst_QDateTime::setMSecsSinceEpochTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (QDateTime test, list) - test.setMSecsSinceEpoch((JULIAN_DAY_2010 + 180) * MSECS_PER_DAY); - } -} - -void tst_QDateTime::toString() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t")); - } -} - -void tst_QDateTime::toStringTextFormat() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toString(Qt::TextDate); - } -} - -void tst_QDateTime::toStringIsoFormat() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toString(Qt::ISODate); - } -} - -void tst_QDateTime::addDays() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.addDays(1); - } -} - -void tst_QDateTime::addDaysTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - QDateTime result = test.addDays(1); - } -} - -void tst_QDateTime::addMSecs() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.addMSecs(1); - } -} - -void tst_QDateTime::addMSecsTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); - QBENCHMARK { - foreach (const QDateTime &test, list) - QDateTime result = test.addMSecs(1); - } -} - -void tst_QDateTime::toTimeSpec() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toTimeSpec(Qt::UTC); - } -} - -void tst_QDateTime::toOffsetFromUtc() -{ - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.toOffsetFromUtc(3600); - } -} - -void tst_QDateTime::daysTo() -{ - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.daysTo(other); - } -} - -void tst_QDateTime::msecsTo() -{ - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - test.msecsTo(other); - } -} - -void tst_QDateTime::equivalent() -{ - bool result; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test == other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::equivalentUtc() -{ - bool result = false; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test == other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::lessThan() -{ - bool result = false; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test < other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::lessThanUtc() -{ - bool result = false; - QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC); - QList list; - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); - QBENCHMARK { - foreach (const QDateTime &test, list) - result = (test < other); - } - Q_UNUSED(result) -} - -void tst_QDateTime::currentDateTime() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::currentDateTime(); - } -} - -void tst_QDateTime::currentDate() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDate::currentDate(); - } -} - -void tst_QDateTime::currentTime() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QTime::currentTime(); - } -} - -void tst_QDateTime::currentDateTimeUtc() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::currentDateTimeUtc(); - } -} - -void tst_QDateTime::currentMSecsSinceEpoch() -{ - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::currentMSecsSinceEpoch(); - } -} - -void tst_QDateTime::fromString() -{ - QString format = "yyyy-MM-dd hh:mm:ss.zzz"; - QString input = "2010-01-01 13:12:11.999"; - QVERIFY(QDateTime::fromString(input, format).isValid()); - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::fromString(input, format); - } -} - -void tst_QDateTime::fromStringText() -{ - QString input = "Wed Jan 2 01:02:03.000 2013 GMT"; - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::fromString(input, Qt::TextDate); - } -} - -void tst_QDateTime::fromStringIso() -{ - QString input = "2010-01-01T13:28:34.999Z"; - QBENCHMARK { - for (int i = 0; i < 1000; ++i) - QDateTime::fromString(input, Qt::ISODate); - } -} - -void tst_QDateTime::fromMSecsSinceEpoch() -{ - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime); - } -} - -void tst_QDateTime::fromMSecsSinceEpochUtc() -{ - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC); - } -} - -void tst_QDateTime::fromMSecsSinceEpochTz() -{ - QTimeZone cet = QTimeZone("Europe/Oslo"); - QBENCHMARK { - for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) - QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet); - } -} - -QTEST_MAIN(tst_QDateTime) - -#include "main.moc" diff --git a/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro b/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro deleted file mode 100644 index a85e7346c6..0000000000 --- a/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro +++ /dev/null @@ -1,4 +0,0 @@ -TARGET = tst_bench_qdatetime -QT = core testlib - -SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qtimezone/main.cpp b/tests/benchmarks/corelib/tools/qtimezone/main.cpp deleted file mode 100644 index 65455a7261..0000000000 --- a/tests/benchmarks/corelib/tools/qtimezone/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -class tst_QTimeZone : public QObject -{ - Q_OBJECT - -private Q_SLOTS: - void isTimeZoneIdAvailable(); -}; - -void tst_QTimeZone::isTimeZoneIdAvailable() -{ - const QList available = QTimeZone::availableTimeZoneIds(); - QBENCHMARK { - for (const QByteArray &id : available) - QVERIFY(QTimeZone::isTimeZoneIdAvailable(id)); - } -} - -QTEST_MAIN(tst_QTimeZone) - -#include "main.moc" diff --git a/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro b/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro deleted file mode 100644 index d0531b568b..0000000000 --- a/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro +++ /dev/null @@ -1,4 +0,0 @@ -TARGET = tst_bench_qtimezone -QT = core testlib - -SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro index ca9c0a6f89..33cbe00438 100644 --- a/tests/benchmarks/corelib/tools/tools.pro +++ b/tests/benchmarks/corelib/tools/tools.pro @@ -5,7 +5,6 @@ SUBDIRS = \ qbytearray \ qcontiguouscache \ qcryptographichash \ - qdatetime \ qlist \ qlocale \ qmap \ @@ -15,7 +14,6 @@ SUBDIRS = \ qstring \ qstringbuilder \ qstringlist \ - qtimezone \ qvector \ qalgorithms -- cgit v1.2.3 From 3e75c2965c96fa014ab74121e84d623fd04a27f7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 10 Jun 2019 00:09:10 +0200 Subject: Remove QLatin1Literal usages That's an undocumented Qt 4/3/2 remnant, start remove usages. Fix incorrect include header in qclass_lib_map.h as a drive-by. Change-Id: I939be2621bc03e5c75f7e3f152546d3af6d37b91 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- tests/benchmarks/corelib/tools/qstringbuilder/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/benchmarks') diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp b/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp index d0dfe3b1a7..0de6d33846 100644 --- a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp +++ b/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp @@ -401,7 +401,7 @@ private slots: } private: - const QLatin1Literal l1literal; + const QLatin1String l1literal; const QLatin1String l1string; const QByteArray ba; const QString string; -- cgit v1.2.3