From fd8b35a121c939e99d64adfb2a08870915802858 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Sat, 22 Feb 2025 15:30:56 +0100 Subject: [PATCH] Add a benchmark for QTimeZone::utc On my machine this gives me: ``` ********* Start testing of tst_QTimeZone ********* Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20250207), arch unknown PASS : tst_QTimeZone::initTestCase() PASS : tst_QTimeZone::utc() RESULT : tst_QTimeZone::utc(): 358.686871 nsecs per iteration (total: 358,686,513, iterations: 999999) 896.524312 CPU cycles per iteration, 2,5 GHz (total: 896,523,416, iterations: 999999) 2,227.000427 instructions per iteration, 2,484 instr/cycle (total: 2,226,998,200, iterations: 999999) 560.000375 branch instructions per iteration, 1,56 G/sec (total: 559,999,815, iterations: 999999) PASS : tst_QTimeZone::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 374ms ********* Finished testing of tst_QTimeZone ********* ``` Profiling shows some quite unexpected code paths that I will try to optimize in follow-up patches. Note that this function can be called frequently when deserializing QDateTime over a QDataStream e.g. - I have stumbled over it while profiling some KDE PIM code in akonadi. Pick-to: 6.5 5.15 Change-Id: I7439df53ae8512c766f63cb4b0d4f33d14aa3a01 Reviewed-by: Thiago Macieira (cherry picked from commit 29c7beac2e0065cc0d03b9db6a701f7c690c6f56) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit c4618d6020b1ab568f40338fb715142d8fe01445) --- .../corelib/time/qtimezone/tst_bench_qtimezone.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp index 6c1f51983f..ed3c222824 100644 --- a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp +++ b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp @@ -18,6 +18,7 @@ private Q_SLOTS: #if QT_CONFIG(timezone) void isTimeZoneIdAvailable(); void systemTimeZone(); + void utc(); void zoneByName_data(); void zoneByName(); void displayName_data(); @@ -72,6 +73,14 @@ void tst_QTimeZone::systemTimeZone() QTimeZone::systemTimeZone(); } } + +void tst_QTimeZone::utc() +{ + QBENCHMARK { + QTimeZone::utc(); + } +} + void tst_QTimeZone::zoneByName_data() { QTest::addColumn("name");