#include #include #include #include #include int main(int argc, char *argv[]) { using namespace std::chrono; using Clock = steady_clock; const std::time_t testTime = 1732107915; const int NumSteps = 50000; const auto t1 = Clock::now(); for (int64_t i = 0; i < NumSteps; ++i) const auto resL = QDateTime::fromSecsSinceEpoch(testTime); const auto t2 = Clock::now(); for (int64_t i = 0; i < NumSteps; ++i) { #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) const auto resU = QDateTime::fromSecsSinceEpoch(testTime, Qt::UTC); #else const auto resU = QDateTime::fromSecsSinceEpoch(testTime, QTimeZone::UTC); #endif } const auto t3 = Clock::now(); qDebug().nospace() << "LocalTime: " << duration_cast(t2 - t1).count(); qDebug().nospace() << "UTC: " << duration_cast(t3 - t2).count(); qDebug().nospace() << "LocalTime to UTC Ratio: " << (static_cast((t2 - t1).count()) / (t3 - t2).count()); return 0; }