| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QBENCHMARK_H |
| 5 | #define QBENCHMARK_H |
| 6 | |
| 7 | #include <QtTest/qttestglobal.h> |
| 8 | #include <QtTest/qbenchmarkmetric.h> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | |
| 13 | namespace QTest |
| 14 | { |
| 15 | |
| 16 | // |
| 17 | // W A R N I N G |
| 18 | // ------------- |
| 19 | // |
| 20 | // The QBenchmarkIterationController class is not a part of the |
| 21 | // Qt Test API. It exists purely as an implementation detail. |
| 22 | // |
| 23 | // |
| 24 | class Q_TESTLIB_EXPORT QBenchmarkIterationController |
| 25 | { |
| 26 | public: |
| 27 | enum RunMode { RepeatUntilValidMeasurement, RunOnce }; |
| 28 | QBenchmarkIterationController(); |
| 29 | QBenchmarkIterationController(RunMode runMode); |
| 30 | ~QBenchmarkIterationController(); |
| 31 | bool isDone() const noexcept; |
| 32 | void next() noexcept; |
| 33 | int i; |
| 34 | }; |
| 35 | |
| 36 | } |
| 37 | |
| 38 | // --- BEGIN public API --- |
| 39 | |
| 40 | #define QBENCHMARK \ |
| 41 | for (QTest::QBenchmarkIterationController _q_iteration_controller; \ |
| 42 | _q_iteration_controller.isDone() == false; _q_iteration_controller.next()) |
| 43 | |
| 44 | #define QBENCHMARK_ONCE \ |
| 45 | for (QTest::QBenchmarkIterationController _q_iteration_controller(QTest::QBenchmarkIterationController::RunOnce); \ |
| 46 | _q_iteration_controller.isDone() == false; _q_iteration_controller.next()) |
| 47 | |
| 48 | namespace QTest |
| 49 | { |
| 50 | void Q_TESTLIB_EXPORT setBenchmarkResult(qreal result, QBenchmarkMetric metric); |
| 51 | } |
| 52 | |
| 53 | // --- END public API --- |
| 54 | |
| 55 | QT_END_NAMESPACE |
| 56 | |
| 57 | #endif // QBENCHMARK_H |
| 58 | |