Optimize QTimeZone::utc()
Instead of using the QTimeZone ctor taking a string representing
UTC which then first needs to be parsed, use the offset-from-UTC
ctor with an offset of 0.
This approach is much faster, compare the following results for
the tst_QTimeZone::utc benchmark as built on my machine with:
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
Before:
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)
After:
102.004937 nsecs per iteration (total: 102,004,835, iterations: 999999)
452.836869 CPU cycles per iteration, 4,44 GHz (total: 452,836,417, iterations: 999999)
1,182.801068 instructions per iteration, 2,612 instr/cycle (total: 1,182,799,886, iterations: 999999)
267.143901 branch instructions per iteration, 2,62 G/sec (total: 267,143,634, iterations: 999999)
Relative Delta:
before after improvement
nsecs 358.7 102.0 3.52x
cycles 896.5 452.8 1.98x
instr. 2227.0 1182.8 1.88x
branch 560.0 267.1 2.10x
This is quite a significant change for such a trivial patch.
Change-Id: I5872fe8f1158ff9f6bf306ca8b069559cb59beec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 765193693982abdbc53910ff0d7d1149332ca83e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 22e66638a6c984d366057d1bb0c6de6dc65df373)
bb10
parent
26e3a06aca
commit
de5b83ac86
|
|
@ -1451,7 +1451,7 @@ QTimeZone QTimeZone::systemTimeZone()
|
|||
*/
|
||||
QTimeZone QTimeZone::utc()
|
||||
{
|
||||
return QTimeZone(QTimeZonePrivate::utcQByteArray());
|
||||
return QTimeZone(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue