diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-11-15 09:54:42 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-11-15 23:40:24 +0100 |
commit | b08ba96fd0eed8517a8a60c0d8d4064a7ab90498 (patch) | |
tree | edc3121052f03778bd98a53cf873cd7c66bb5dd4 /src/testlib/qbenchmark.cpp | |
parent | 6017695bfa98d8d9a6e5977ec80aafa1a4d3ee4d (diff) |
QBENCHMARK: mark loop operations as noexcept
Tell the compiler that next() and isDone() cannot throw, so it doesn't
need to create exception handling code. This might yield more faithful
benchmark results for micro-benchmarks.
As a drive-by, mark isDone() as const, too.
Change-Id: Ifac3d9ee2f4df524e780fd07423e26bb5e87dab3
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Isak Fyksen <isak.fyksen@qt.io>
Diffstat (limited to 'src/testlib/qbenchmark.cpp')
-rw-r--r-- | src/testlib/qbenchmark.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index 4a8bd72ee9..af6ee5f7c6 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -167,7 +167,7 @@ QTest::QBenchmarkIterationController::~QBenchmarkIterationController() /*! \internal */ -bool QTest::QBenchmarkIterationController::isDone() +bool QTest::QBenchmarkIterationController::isDone() const noexcept { if (QBenchmarkTestMethodData::current->runOnce) return i > 0; @@ -176,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; } |