Qt 4.8
Classes | Namespaces | Macros | Functions
qbenchmark.h File Reference
#include <QtTest/qtest_global.h>
#include <QtTest/qbenchmarkmetric.h>

Go to the source code of this file.

Classes

class  QTest::QBenchmarkIterationController
 The QBenchmarkIterationController class is used by the QBENCHMARK macro to drive the benchmarking loop. More...
 

Namespaces

 QTest
 The QTest namespace contains all the functions and declarations that are related to the QTestLib tool.
 

Macros

#define QBENCHMARK
 This macro is used to measure the performance of code within a test. More...
 
#define QBENCHMARK_ONCE
 The QBENCHMARK_ONCE macro is for measuring performance of a code block by running it once. More...
 

Functions

void Q_TESTLIB_EXPORT QTest::setBenchmarkResult (qreal result, QBenchmarkMetric metric)
 Sets the benchmark result for this test function to result. More...
 

Macro Definition Documentation

◆ QBENCHMARK

#define QBENCHMARK
Value:
for (QTest::QBenchmarkIterationController __iteration_controller; \
__iteration_controller.isDone() == false; __iteration_controller.next())
The QBenchmarkIterationController class is used by the QBENCHMARK macro to drive the benchmarking loo...
Definition: qbenchmark.h:65

This macro is used to measure the performance of code within a test.

The code to be benchmarked is contained within a code block following this macro.

For example:

void TestBenchmark::simple()
{
QString str1 = QLatin1String("This is a test string");
QString str2 = QLatin1String("This is a test string");
QCOMPARE(str1.localeAwareCompare(str2), 0);
str1.localeAwareCompare(str2);
}
}
See also
{QTestLib Manual::Creating a Benchmark}{Creating a Benchmark}, {Chapter 5: Writing a Benchmark}{Writing a Benchmark}

◆ QBENCHMARK_ONCE

#define QBENCHMARK_ONCE
Value:
__iteration_controller.isDone() == false; __iteration_controller.next())
The QBenchmarkIterationController class is used by the QBENCHMARK macro to drive the benchmarking loo...
Definition: qbenchmark.h:65

The QBENCHMARK_ONCE macro is for measuring performance of a code block by running it once.

Since
4.6

This macro is used to measure the performance of code within a test. The code to be benchmarked is contained within a code block following this macro.

Unlike QBENCHMARK, the contents of the contained code block is only run once. The elapsed time will be reported as "0" if it's to short to be measured by the selected backend. (Use)

See also
{QTestLib Manual::Creating a Benchmark}{Creating a Benchmark}, {Chapter 5: Writing a Benchmark}{Writing a Benchmark}