aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/benchmarker.h
blob: 8fef36cd6c4c6ad3c88f0bf1a20e0debd8b69c65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "utils_global.h"

#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 &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 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;
    QString m_testcase;
};

} // namespace Utils