diff options
Diffstat (limited to 'src/testlib/qbenchmark.cpp')
-rw-r--r-- | src/testlib/qbenchmark.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index 00dded0394..af6ee5f7c6 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -96,10 +96,13 @@ int QBenchmarkTestMethodData::adjustIterationCount(int suggestion) return iterationCount; } -void QBenchmarkTestMethodData::setResult( - qreal value, QTest::QBenchmarkMetric metric, bool setByMacro) +void QBenchmarkTestMethodData::setResults(const QList<QBenchmarkMeasurerBase::Measurement> &list, + bool setByMacro) { bool accepted = false; + QBenchmarkMeasurerBase::Measurement firstMeasurement = {}; + if (!list.isEmpty()) + firstMeasurement = list.constFirst(); // Always accept the result if the iteration count has been // specified on the command line with -iterations. @@ -114,9 +117,9 @@ void QBenchmarkTestMethodData::setResult( // Test the result directly without calling the measurer if the minimum time // has been specified on the command line with -minimumvalue. else if (QBenchmarkGlobalData::current->walltimeMinimum != -1) - accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum); + accepted = (firstMeasurement.value > QBenchmarkGlobalData::current->walltimeMinimum); else - accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(value); + accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(firstMeasurement); // Accept the result or double the number of iterations. if (accepted) @@ -124,8 +127,10 @@ void QBenchmarkTestMethodData::setResult( else iterationCount *= 2; - this->result = QBenchmarkResult( - QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro); + valid = true; + results.reserve(list.size()); + for (auto m : list) + results.emplaceBack(QBenchmarkGlobalData::current->context, m, iterationCount, setByMacro); } /*! @@ -133,7 +138,7 @@ void QBenchmarkTestMethodData::setResult( \internal The QBenchmarkIterationController class is used by the QBENCHMARK macro to - drive the benchmarking loop. It is repsonsible for starting and stopping + drive the benchmarking loop. It is responsible for starting and stopping the timing measurements as well as calling the result reporting functions. */ @@ -157,13 +162,12 @@ QTest::QBenchmarkIterationController::QBenchmarkIterationController() */ QTest::QBenchmarkIterationController::~QBenchmarkIterationController() { - const qreal result = QTest::endBenchmarkMeasurement(); - QBenchmarkTestMethodData::current->setResult(result, QBenchmarkGlobalData::current->measurer->metricType()); + QBenchmarkTestMethodData::current->setResults(QTest::endBenchmarkMeasurement()); } /*! \internal */ -bool QTest::QBenchmarkIterationController::isDone() +bool QTest::QBenchmarkIterationController::isDone() const noexcept { if (QBenchmarkTestMethodData::current->runOnce) return i > 0; @@ -172,14 +176,14 @@ bool QTest::QBenchmarkIterationController::isDone() /*! \internal */ -void QTest::QBenchmarkIterationController::next() +void QTest::QBenchmarkIterationController::next() noexcept { ++i; } /*! \internal */ -int QTest::iterationCount() +int QTest::iterationCount() noexcept { return QBenchmarkTestMethodData::current->iterationCount; } @@ -209,7 +213,7 @@ void QTest::beginBenchmarkMeasurement() /*! \internal */ -quint64 QTest::endBenchmarkMeasurement() +QList<QBenchmarkMeasurerBase::Measurement> QTest::endBenchmarkMeasurement() { // the clock is ticking before the line below, don't add code here. return QBenchmarkGlobalData::current->measurer->stop(); @@ -234,7 +238,7 @@ quint64 QTest::endBenchmarkMeasurement() */ void QTest::setBenchmarkResult(qreal result, QTest::QBenchmarkMetric metric) { - QBenchmarkTestMethodData::current->setResult(result, metric, false); + QBenchmarkTestMethodData::current->setResult({ result, metric }, false); } template <typename T> |