diff options
author | Morten Sorvig <msorvig@trolltech.com> | 2009-08-10 08:14:12 (GMT) |
---|---|---|
committer | Morten Sorvig <msorvig@trolltech.com> | 2009-08-10 08:20:15 (GMT) |
commit | 7aa2d76dfc4a107f38c5cb0aac00a0b31d0fbbb6 (patch) | |
tree | eeeef851de0e762822380f9c77645c489bab4567 /src/testlib/qbenchmark.h | |
parent | 2be387f3e94f84cf0167cdc3871de0d0af85c62d (diff) | |
download | Qt-7aa2d76dfc4a107f38c5cb0aac00a0b31d0fbbb6.zip Qt-7aa2d76dfc4a107f38c5cb0aac00a0b31d0fbbb6.tar.gz Qt-7aa2d76dfc4a107f38c5cb0aac00a0b31d0fbbb6.tar.bz2 |
Add QBENCMARK_ONCE to QTestLib.
The code block associated with QBENCHMARK_ONCE macro will only be executed once,
whether the backend returns a valid result or not. The "-iterations" command line
argument is also ignored.
This is useful for benchmarking code that has side effects.
Revby: jasplin
Diffstat (limited to 'src/testlib/qbenchmark.h')
-rw-r--r-- | src/testlib/qbenchmark.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/testlib/qbenchmark.h b/src/testlib/qbenchmark.h index c06bfc0..87d34e7 100644 --- a/src/testlib/qbenchmark.h +++ b/src/testlib/qbenchmark.h @@ -64,7 +64,8 @@ namespace QTest class Q_TESTLIB_EXPORT QBenchmarkIterationController { public: - QBenchmarkIterationController(); + enum RunMode { RepeatUntilValidMeasurement, RunOnce }; + QBenchmarkIterationController(RunMode runMode); ~QBenchmarkIterationController(); bool isDone(); void next(); @@ -74,7 +75,12 @@ public: } #define QBENCHMARK \ - for (QTest::QBenchmarkIterationController __iteration_controller; __iteration_controller.isDone() == false; __iteration_controller.next()) + for (QTest::QBenchmarkIterationController __iteration_controller(QTest::QBenchmarkIterationController::RepeatUntilValidMeasurement); \ + __iteration_controller.isDone() == false; __iteration_controller.next()) + +#define QBENCHMARK_ONCE \ + for (QTest::QBenchmarkIterationController __iteration_controller(QTest::QBenchmarkIterationController::RunOnce); \ + __iteration_controller.isDone() == false; __iteration_controller.next()) QT_END_NAMESPACE |