From 9c63c30d90aafbc1193df5a2d67e8a52e8213aad Mon Sep 17 00:00:00 2001 From: lordmulder Date: Wed, 29 Mar 2017 23:42:39 +0200 Subject: [PATCH] Measure time for update check (for debugging). --- src/version.h | 2 +- src/win_updater.cpp | 19 ++++++++++++++++--- src/win_updater.h | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index b79c0b6..3916175 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 7 #define VER_X264_PATCH 9 -#define VER_X264_BUILD 1094 +#define VER_X264_BUILD 1095 #define VER_X264_PORTABLE_EDITION (0) diff --git a/src/win_updater.cpp b/src/win_updater.cpp index 070b60e..874224a 100644 --- a/src/win_updater.cpp +++ b/src/win_updater.cpp @@ -44,6 +44,7 @@ #include #include #include +#include /////////////////////////////////////////////////////////////////////////////// @@ -189,9 +190,10 @@ void UpdaterDialog::keyPressEvent(QKeyEvent *event) break; case Qt::Key_F11: { - const QString logFilePath = MUtils::make_temp_file(MUtils::temp_folder(), "log", true); + const QString logFilePath = MUtils::make_temp_file(MUtils::temp_folder(), "txt", true); if (!logFilePath.isEmpty()) { + qWarning("Write log to: '%s'", MUTILS_UTF8(logFilePath)); QFile logFile(logFilePath); if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { @@ -298,8 +300,12 @@ void UpdaterDialog::checkForUpdates(void) //Clear log m_logFile.clear(); + //Init timer + m_elapsed.reset(new QElapsedTimer()); + m_elapsed->start(); + //Start the updater thread - QTimer::singleShot(250, m_thread.data(), SLOT(start())); + QTimer::singleShot(125, m_thread.data(), SLOT(start())); } void UpdaterDialog::threadStatusChanged(int status) @@ -367,12 +373,19 @@ void UpdaterDialog::threadStatusChanged(int status) void UpdaterDialog::threadFinished(void) { m_success = m_thread->getSuccess(); - QTimer::singleShot((m_success ? 1000 : 0), this, SLOT(updateFinished())); ui->labelCancel->hide(); + QTimer::singleShot((m_success ? 500 : 0), this, SLOT(updateFinished())); } void UpdaterDialog::updateFinished(void) { + //Query the timer, if available + if (!m_elapsed.isNull()) + { + const quint64 elapsed = m_elapsed->restart(); + qDebug("Update check completed after %.2f seconds.", double(elapsed) / 1000.0); + } + //Restore cursor QApplication::restoreOverrideCursor(); diff --git a/src/win_updater.h b/src/win_updater.h index 5896223..ef0d3af 100644 --- a/src/win_updater.h +++ b/src/win_updater.h @@ -25,6 +25,7 @@ #include class QMovie; +class QElapsedTimer; class SysinfoModel; namespace Ui @@ -89,6 +90,7 @@ private: QScopedPointer m_animator; QScopedPointer m_thread; + QScopedPointer m_elapsed; unsigned long m_updaterProcess; QStringList m_logFile;