diff options
Diffstat (limited to 'src/testlib/qbenchmark_p.h')
-rw-r--r-- | src/testlib/qbenchmark_p.h | 81 |
1 files changed, 22 insertions, 59 deletions
diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index 93b5becb2b..902b092b16 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QBENCHMARK_P_H #define QBENCHMARK_P_H @@ -91,37 +55,33 @@ struct QBenchmarkContext QBenchmarkContext() = default; }; -Q_DECLARE_TYPEINFO(QBenchmarkContext, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QBenchmarkContext, Q_RELOCATABLE_TYPE); class QBenchmarkResult { public: QBenchmarkContext context; - qreal value = -1; + QBenchmarkMeasurerBase::Measurement measurement = { -1, QTest::FramesPerSecond }; int iterations = -1; - QTest::QBenchmarkMetric metric = QTest::FramesPerSecond; bool setByMacro = true; - bool valid = false; QBenchmarkResult() = default; QBenchmarkResult( - const QBenchmarkContext &context, const qreal value, const int iterations, - QTest::QBenchmarkMetric metric, bool setByMacro) + const QBenchmarkContext &context, QBenchmarkMeasurerBase::Measurement m, + const int iterations, bool setByMacro) : context(context) - , value(value) + , measurement(m) , iterations(iterations) - , metric(metric) , setByMacro(setByMacro) - , valid(true) { } bool operator<(const QBenchmarkResult &other) const { - return (value / iterations) < (other.value / other.iterations); + return (measurement.value / iterations) < (other.measurement.value / other.iterations); } }; -Q_DECLARE_TYPEINFO(QBenchmarkResult, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QBenchmarkResult, Q_RELOCATABLE_TYPE); /* The QBenchmarkGlobalData class stores global benchmark-related data. @@ -155,10 +115,10 @@ private: }; /* - The QBenchmarkTestMethodData class stores all benchmark-related data - for the current test case. QBenchmarkTestMethodData:current is - created at the beginning of qInvokeTestMethod() and cleared at - the end. + The QBenchmarkTestMethodData class stores all benchmark-related data for the + current test case. QBenchmarkTestMethodData:current is set to a local + instance at the beginning of TestMethods::invokeTest() and cleared by its + destructor when that instance drops out of scope. */ class Q_TESTLIB_EXPORT QBenchmarkTestMethodData { @@ -172,12 +132,15 @@ public: void beginDataRun(); void endDataRun(); - bool isBenchmark() const { return result.valid; } + bool isBenchmark() const { return valid; } bool resultsAccepted() const { return resultAccepted; } int adjustIterationCount(int suggestion); - void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true); + void setResults(const QList<QBenchmarkMeasurerBase::Measurement> &m, bool setByMacro = true); + void setResult(QBenchmarkMeasurerBase::Measurement m, bool setByMacro = true) + { setResults({ m }, setByMacro); } - QBenchmarkResult result; + QList<QBenchmarkResult> results; + bool valid = false; bool resultAccepted = false; bool runOnce = false; int iterationCount = -1; @@ -186,12 +149,12 @@ public: // low-level API: namespace QTest { - int iterationCount(); + int iterationCount() noexcept; void setIterationCountHint(int count); void setIterationCount(int count); - Q_TESTLIB_EXPORT void beginBenchmarkMeasurement(); - Q_TESTLIB_EXPORT quint64 endBenchmarkMeasurement(); + void beginBenchmarkMeasurement(); + QList<QBenchmarkMeasurerBase::Measurement> endBenchmarkMeasurement(); } QT_END_NAMESPACE |