ClangTools: Print elapsed time on finish

...as this is useful to know for some bigger runs.

Change-Id: Ib4cc68ea4a3bed21ac7e632213e92e26be03d978
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-11-29 09:24:05 +01:00
parent ab47d562a1
commit 07490e76de
2 changed files with 11 additions and 0 deletions

View File

@@ -326,6 +326,7 @@ void ClangToolRunWorker::start()
}
reportStarted();
m_elapsed.start();
while (m_runners.size() < parallelRuns && !m_queue.isEmpty())
analyzeNextFile();
@@ -343,6 +344,13 @@ void ClangToolRunWorker::stop()
m_progress.reportFinished();
reportStopped();
// Print elapsed time since start
const QTime format = QTime(0, 0, 0, 0).addMSecs(m_elapsed.elapsed() + 500);
QString time = format.toString("h:mm:ss");
if (time.startsWith("0:"))
time.remove(0, 2); // Don't display zero hours
appendMessage(tr("Elapsed time: %1.") .arg(time), NormalMessageFormat);
}
void ClangToolRunWorker::analyzeNextFile()

View File

@@ -34,6 +34,7 @@
#include <utils/environment.h>
#include <utils/temporarydirectory.h>
#include <QElapsedTimer>
#include <QFutureInterface>
#include <QSet>
#include <QStringList>
@@ -123,6 +124,8 @@ private:
int m_initialQueueSize = 0;
QSet<QString> m_filesAnalyzed;
QSet<QString> m_filesNotAnalyzed;
QElapsedTimer m_elapsed;
};
} // namespace Internal