Add environment variable for internal profiling

Change-Id: Idd9197a7610aec550945fc0cb1c0a1dd833b7cba
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Christian Stenger
2017-11-22 15:16:09 +01:00
parent bf3c67e0d0
commit 45c667d52c

View File

@@ -25,7 +25,9 @@
#include "benchmarker.h"
#include <QCoreApplication>
#include <QLoggingCategory>
#include <QTimer>
static Q_LOGGING_CATEGORY(benchmarksLog, "qtc.benchmark");
@@ -68,12 +70,16 @@ void Benchmarker::report(const QString &testsuite,
void Benchmarker::report(const QLoggingCategory &cat, const QString &testsuite, const QString &testcase,
qint64 ms, const QString &tags)
{
static const QByteArray quitAfter = qgetenv("QTC_QUIT_AFTER_BENCHMARK");
QString t = "unit=ms";
if (!tags.isEmpty())
t += "," + tags;
qCDebug(cat, "%s::%s: %lld { %s }",
testsuite.toUtf8().data(), testcase.toUtf8().data(), ms, t.toUtf8().data());
const QByteArray testSuite = testsuite.toUtf8();
const QByteArray testCase = testcase.toUtf8();
qCDebug(cat, "%s::%s: %lld { %s }", testSuite.data(), testCase.data(), ms, t.toUtf8().data());
if (!quitAfter.isEmpty() && quitAfter == testSuite + "::" + testCase)
QTimer::singleShot(1000, qApp, &QCoreApplication::quit);
}