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 /tests/auto/selftests | |
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 'tests/auto/selftests')
-rw-r--r-- | tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp | 11 | ||||
-rw-r--r-- | tests/auto/selftests/expected_benchlibwalltime.txt | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp b/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp index de65599..8474144f 100644 --- a/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp +++ b/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp @@ -50,6 +50,7 @@ class tst_BenchlibWalltime: public QObject private slots: void waitForOneThousand(); void waitForFourThousand(); + void qbenchmark_once(); }; void tst_BenchlibWalltime::waitForOneThousand() @@ -66,6 +67,16 @@ void tst_BenchlibWalltime::waitForFourThousand() } } +void tst_BenchlibWalltime::qbenchmark_once() +{ + int iterations = 0; + QBENCHMARK_ONCE { + ++iterations; + } + QCOMPARE(iterations, 1); +} + + QTEST_MAIN(tst_BenchlibWalltime) #include "tst_benchlibwalltime.moc" diff --git a/tests/auto/selftests/expected_benchlibwalltime.txt b/tests/auto/selftests/expected_benchlibwalltime.txt index 03f2465..ec2d020 100644 --- a/tests/auto/selftests/expected_benchlibwalltime.txt +++ b/tests/auto/selftests/expected_benchlibwalltime.txt @@ -7,6 +7,9 @@ PASS : tst_BenchlibWalltime::waitForOneThousand() RESULT : tst_BenchlibWalltime::waitForFourThousand(): 4,000 msec per iteration (total: 4000, iterations: 1) PASS : tst_BenchlibWalltime::waitForFourThousand() +RESULT : tst_BenchlibWalltime::qbenchmark_once(): + 0 msec per iteration (total: 0, iterations: 1) +PASS : tst_BenchlibWalltime::qbenchmark_once() PASS : tst_BenchlibWalltime::cleanupTestCase() -Totals: 4 passed, 0 failed, 0 skipped +Totals: 5 passed, 0 failed, 0 skipped ********* Finished testing of tst_BenchlibWalltime ********* |