diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-03-25 15:41:53 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-31 17:42:47 +0200 |
commit | 3febcd6286a3cd22db4f294e7f31a94c07c51fb0 (patch) | |
tree | 7a9809526d944d6ccb1c5df706573ca51ba4e775 /tests | |
parent | 64dd5a8183eb0d80f31b8ac0c2a59066e769ae79 (diff) |
More startOfDay() fixes, in tst_bench_QDateTime
Update a QDateTime benchmark to use QDate::startOfDay() when setting
up its lists of date-times in helper functions, and to use noon as the
moment in the day in a creation test. Also move creation of a QTime
outside the loop: we're testing speed of creation of QDateTime here,
not QTime (and were already using the most trivial QTime constructor).
Change-Id: I26bf3369aae84a802ab03791f7341e107fede87c
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp b/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp index 302cf80abf..59ef9a1e68 100644 --- a/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp +++ b/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -107,7 +107,7 @@ QList<QDateTime> tst_QDateTime::daily(qint64 start, qint64 end) QList<QDateTime> list; list.reserve(end - start); for (int jd = start; jd < end; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0))); + list.append(QDateTime(QDate::fromJulianDay(jd).startOfDay())); return list; } @@ -117,15 +117,16 @@ QList<QDateTime> tst_QDateTime::norse(qint64 start, qint64 end) QList<QDateTime> list; list.reserve(end - start); for (int jd = start; jd < end; ++jd) - list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet)); + list.append(QDateTime(QDate::fromJulianDay(jd).startOfDay(cet))); return list; } void tst_QDateTime::create() { + const QTime noon = QTime::fromMSecsSinceStartOfDay(43200); QBENCHMARK { for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) { - QDateTime test(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)); + QDateTime test(QDate::fromJulianDay(jd), noon); Q_UNUSED(test); } } |