diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-09-29 16:16:20 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-10-08 20:03:22 +0200 |
commit | e5183c49dd0f1cc0698755e6821dce2805571e45 (patch) | |
tree | d8be3bd67691613082e1d96f378bcb21c340cb5b /src/tools | |
parent | ce59ccb3341223cda4f7ef2469d86326c6a116e8 (diff) |
androiddeployqt: Use QElapsedTimer to get elapsed time
No need to reinevent the wheel. Also, use nanoseconds
now that we have the precision available.
Change-Id: I287d06198edc3f5bdf7f85bd5f3e235b1fea95a3
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/androiddeployqt/main.cpp | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 7f09d32cef..431fa51d9e 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -36,10 +36,10 @@ #include <QDebug> #include <QDataStream> #include <QXmlStreamReader> -#include <QDateTime> #include <QStandardPaths> #include <QUuid> #include <QDirIterator> +#include <QElapsedTimer> #include <QRegularExpression> #include <depfile_shared.h> @@ -58,21 +58,6 @@ #define QT_POPEN_READ "r" #endif -class ActionTimer -{ - qint64 started; -public: - ActionTimer() = default; - void start() - { - started = QDateTime::currentMSecsSinceEpoch(); - } - int elapsed() - { - return int(QDateTime::currentMSecsSinceEpoch() - started); - } -}; - static const bool mustReadOutputAnyway = true; // pclose seems to return the wrong error code unless we read the output static QStringList dependenciesForDepfile; @@ -165,7 +150,7 @@ struct Options bool timing; bool build; bool auxMode; - ActionTimer timer; + QElapsedTimer timer; // External tools QString sdkPath; @@ -3146,7 +3131,7 @@ int main(int argc, char *argv[]) return CannotReadInputFile; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Read input file\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Read input file\n", options.timer.nsecsElapsed()); fprintf(stdout, // "012345678901234567890123456789012345678901234567890123456789012345678901" @@ -3176,13 +3161,13 @@ int main(int argc, char *argv[]) if (!androidTemplatetCopied && options.build && !options.auxMode) { cleanAndroidFiles(options); if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Cleaned Android file\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Cleaned Android file\n", options.timer.nsecsElapsed()); if (!copyAndroidTemplate(options)) return CannotCopyAndroidTemplate; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Copied Android template\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Copied Android template\n", options.timer.nsecsElapsed()); androidTemplatetCopied = true; } @@ -3190,42 +3175,42 @@ int main(int argc, char *argv[]) return CannotReadDependencies; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Read dependencies\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Read dependencies\n", options.timer.nsecsElapsed()); if (!copyQtFiles(&options)) return CannotCopyQtFiles; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Copied Qt files\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Copied Qt files\n", options.timer.nsecsElapsed()); if (!copyAndroidExtraLibs(&options)) return CannotCopyAndroidExtraLibs; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Copied extra libs\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ms: Copied extra libs\n", options.timer.nsecsElapsed()); if (!copyAndroidExtraResources(&options)) return CannotCopyAndroidExtraResources; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Copied extra resources\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Copied extra resources\n", options.timer.nsecsElapsed()); if (!options.auxMode) { if (!copyStdCpp(&options)) return CannotCopyGnuStl; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Copied GNU STL\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Copied GNU STL\n", options.timer.nsecsElapsed()); } if (!containsApplicationBinary(&options)) return CannotFindApplicationBinary; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Checked for application binary\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Checked for application binary\n", options.timer.nsecsElapsed()); if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Bundled Qt libs\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Bundled Qt libs\n", options.timer.nsecsElapsed()); } if (!createRcc(options)) @@ -3243,22 +3228,22 @@ int main(int argc, char *argv[]) return CannotCopyAndroidSources; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Copied android sources\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Copied android sources\n", options.timer.nsecsElapsed()); if (!updateAndroidFiles(options)) return CannotUpdateAndroidFiles; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Updated files\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Updated files\n", options.timer.nsecsElapsed()); if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Created project\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Created project\n", options.timer.nsecsElapsed()); if (!buildAndroidProject(options)) return CannotBuildAndroidProject; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Built project\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Built project\n", options.timer.nsecsElapsed()); if (!options.keyStore.isEmpty() && !signPackage(options)) return CannotSignPackage; @@ -3267,14 +3252,14 @@ int main(int argc, char *argv[]) return CannotCopyApk; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Signed package\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Signed package\n", options.timer.nsecsElapsed()); } if (options.installApk && !installApk(options)) return CannotInstallApk; if (Q_UNLIKELY(options.timing)) - fprintf(stdout, "[TIMING] %d ms: Installed APK\n", options.timer.elapsed()); + fprintf(stdout, "[TIMING] %lld ns: Installed APK\n", options.timer.nsecsElapsed()); if (!options.depFilePath.isEmpty()) writeDependencyFile(options); |