summaryrefslogtreecommitdiffstats
path: root/src/testlib/qbenchmark.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-10-21 11:04:26 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-11-09 02:18:44 -0700
commit985b94215276eebf4acdd2625829d90a27213d64 (patch)
tree9ba8425bb4aa20f5be8478accd694099416331d7 /src/testlib/qbenchmark.cpp
parent0f55580ec5e48d1e56e31de3b264d0f4a336245c (diff)
QBenchlib: pass the metric type alongside the measurement value
And pass the value in a qreal, which is what QBenchlib stores anyway. This increases the code size a little because the conversion from integer to qreal is in multiple places, but doesn't meaningfully increase the overhead: in the SysV ABI, we still return Measurement in registers and even using the floating point registers where applicable. This is the first step in allowing the Perf benchmarker to benchmark more than one event. Change-Id: I3c79b7e08fa346988dfefffd172027a8677f17c0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/testlib/qbenchmark.cpp')
-rw-r--r--src/testlib/qbenchmark.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp
index 9bd6aa0ac7..e2df24ae7d 100644
--- a/src/testlib/qbenchmark.cpp
+++ b/src/testlib/qbenchmark.cpp
@@ -96,8 +96,8 @@ int QBenchmarkTestMethodData::adjustIterationCount(int suggestion)
return iterationCount;
}
-void QBenchmarkTestMethodData::setResult(
- qreal value, QTest::QBenchmarkMetric metric, bool setByMacro)
+void QBenchmarkTestMethodData::setResult(QBenchmarkMeasurerBase::Measurement m,
+ bool setByMacro)
{
bool accepted = false;
@@ -114,9 +114,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 = (m.value > QBenchmarkGlobalData::current->walltimeMinimum);
else
- accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(value);
+ accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(m);
// Accept the result or double the number of iterations.
if (accepted)
@@ -125,7 +125,7 @@ void QBenchmarkTestMethodData::setResult(
iterationCount *= 2;
this->result = QBenchmarkResult(
- QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro);
+ QBenchmarkGlobalData::current->context, m.value, iterationCount, m.metric, setByMacro);
}
/*!
@@ -157,8 +157,8 @@ QTest::QBenchmarkIterationController::QBenchmarkIterationController()
*/
QTest::QBenchmarkIterationController::~QBenchmarkIterationController()
{
- const qreal result = QTest::endBenchmarkMeasurement();
- QBenchmarkTestMethodData::current->setResult(result, QBenchmarkGlobalData::current->measurer->metricType());
+ QBenchmarkMeasurerBase::Measurement measurement = QTest::endBenchmarkMeasurement();
+ QBenchmarkTestMethodData::current->setResult(measurement);
}
/*! \internal
@@ -209,7 +209,7 @@ void QTest::beginBenchmarkMeasurement()
/*! \internal
*/
-quint64 QTest::endBenchmarkMeasurement()
+QBenchmarkMeasurerBase::Measurement QTest::endBenchmarkMeasurement()
{
// the clock is ticking before the line below, don't add code here.
return QBenchmarkGlobalData::current->measurer->stop();
@@ -234,7 +234,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>