diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-10-21 11:04:26 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-11-09 02:18:44 -0700 |
commit | 985b94215276eebf4acdd2625829d90a27213d64 (patch) | |
tree | 9ba8425bb4aa20f5be8478accd694099416331d7 /src/testlib/qbenchmarkmeasurement.cpp | |
parent | 0f55580ec5e48d1e56e31de3b264d0f4a336245c (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/qbenchmarkmeasurement.cpp')
-rw-r--r-- | src/testlib/qbenchmarkmeasurement.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/testlib/qbenchmarkmeasurement.cpp b/src/testlib/qbenchmarkmeasurement.cpp index fab0a689bd..4bd1477640 100644 --- a/src/testlib/qbenchmarkmeasurement.cpp +++ b/src/testlib/qbenchmarkmeasurement.cpp @@ -16,14 +16,14 @@ void QBenchmarkTimeMeasurer::start() time.start(); } -qint64 QBenchmarkTimeMeasurer::stop() +QBenchmarkMeasurerBase::Measurement QBenchmarkTimeMeasurer::stop() { - return time.elapsed(); + return { qreal(time.elapsed()), QTest::WalltimeMilliseconds }; } -bool QBenchmarkTimeMeasurer::isMeasurementAccepted(qint64 measurement) +bool QBenchmarkTimeMeasurer::isMeasurementAccepted(Measurement measurement) { - return (measurement > 50); + return (measurement.value > 50); } int QBenchmarkTimeMeasurer::adjustIterationCount(int suggestion) @@ -41,11 +41,6 @@ int QBenchmarkTimeMeasurer::adjustMedianCount(int) return 1; } -QTest::QBenchmarkMetric QBenchmarkTimeMeasurer::metricType() -{ - return QTest::WalltimeMilliseconds; -} - #ifdef HAVE_TICK_COUNTER // defined in 3rdparty/cycle_p.h void QBenchmarkTickMeasurer::start() @@ -53,13 +48,13 @@ void QBenchmarkTickMeasurer::start() startTicks = getticks(); } -qint64 QBenchmarkTickMeasurer::stop() +QBenchmarkMeasurerBase::Measurement QBenchmarkTickMeasurer::stop() { CycleCounterTicks now = getticks(); - return qRound64(elapsed(now, startTicks)); + return { elapsed(now, startTicks), QTest::CPUTicks }; } -bool QBenchmarkTickMeasurer::isMeasurementAccepted(qint64) +bool QBenchmarkTickMeasurer::isMeasurementAccepted(QBenchmarkMeasurerBase::Measurement) { return true; } @@ -79,11 +74,6 @@ bool QBenchmarkTickMeasurer::needsWarmupIteration() return true; } -QTest::QBenchmarkMetric QBenchmarkTickMeasurer::metricType() -{ - return QTest::CPUTicks; -} - #endif |