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.9 6.8 6.5 5.15
Change-Id: I7439df53ae8512c766f63cb4b0d4f33d14aa3a01
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Milian Wolff 2025-02-22 15:30:56 +01:00
parent c5608c675a
commit 29c7beac2e

View File

@ -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<QByteArray>("name");