forked from qt-creator/qt-creator
Utils: Make Benchmarker log to a configurable loggingcategory
Change-Id: I2bb6b42af775827dae1c1cc41f9dabf63edf58e7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -33,6 +33,13 @@ namespace Utils {
|
||||
|
||||
Benchmarker::Benchmarker(const QString &testsuite, const QString &testcase,
|
||||
const QString &tagData) :
|
||||
Benchmarker(benchmarksLog(), testsuite, testcase, tagData)
|
||||
{ }
|
||||
|
||||
Benchmarker::Benchmarker(const QLoggingCategory &cat,
|
||||
const QString &testsuite, const QString &testcase,
|
||||
const QString &tagData) :
|
||||
m_category(cat),
|
||||
m_tagData(tagData),
|
||||
m_testsuite(testsuite),
|
||||
m_testcase(testcase)
|
||||
@@ -49,17 +56,23 @@ Benchmarker::~Benchmarker()
|
||||
void Benchmarker::report(qint64 ms)
|
||||
{
|
||||
m_timer.invalidate();
|
||||
report(m_testsuite, m_testcase, ms, m_tagData);
|
||||
report(m_category, m_testsuite, m_testcase, ms, m_tagData);
|
||||
}
|
||||
|
||||
void Benchmarker::report(const QString &testsuite, const QString &testcase, qint64 ms,
|
||||
const QString &tags)
|
||||
void Benchmarker::report(const QString &testsuite,
|
||||
const QString &testcase, qint64 ms, const QString &tags)
|
||||
{
|
||||
report(benchmarksLog(), testsuite, testcase, ms, tags);
|
||||
}
|
||||
|
||||
void Benchmarker::report(const QLoggingCategory &cat, const QString &testsuite, const QString &testcase,
|
||||
qint64 ms, const QString &tags)
|
||||
{
|
||||
QString t = "unit=ms";
|
||||
if (!tags.isEmpty())
|
||||
t += "," + tags;
|
||||
|
||||
qCDebug(benchmarksLog, "%s::%s: %lld { %s }",
|
||||
qCDebug(cat, "%s::%s: %lld { %s }",
|
||||
testsuite.toUtf8().data(), testcase.toUtf8().data(), ms, t.toUtf8().data());
|
||||
}
|
||||
|
||||
|
@@ -30,20 +30,30 @@
|
||||
#include <QString>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLoggingCategory;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Benchmarker
|
||||
{
|
||||
public:
|
||||
Benchmarker(const QString &testsuite, const QString &testcase,
|
||||
const QString &tags = QString());
|
||||
const QString &tagData = QString());
|
||||
Benchmarker(const QLoggingCategory &cat, const QString &testsuite, const QString &testcase,
|
||||
const QString &tagData = QString());
|
||||
~Benchmarker();
|
||||
|
||||
void report(qint64 ms);
|
||||
static void report(const QString &testsuite, const QString &testcase, qint64 ms,
|
||||
const QString &tags = QString());
|
||||
static void report(const QString &testsuite, const QString &testcase,
|
||||
qint64 ms, const QString &tags = QString());
|
||||
static void report(const QLoggingCategory &cat,
|
||||
const QString &testsuite, const QString &testcase,
|
||||
qint64 ms, const QString &tags = QString());
|
||||
|
||||
private:
|
||||
const QLoggingCategory &m_category;
|
||||
QElapsedTimer m_timer;
|
||||
QString m_tagData;
|
||||
QString m_testsuite;
|
||||
|
Reference in New Issue
Block a user