January 2018
Intermediate to advanced
486 pages
11h 28m
English
QTest offers the QBENCHMARK and QBENCHMARK_ONCE macros to measure the performance (benchmark) of function calls or any other piece of code. These two macros differ only in the number of times they repeat a piece of code to measure its performance, with the latter, obviously, running the code only once. You can use these macros in the following way:
QBENCHMARK
{
// Piece of code to be benchmarked
}
Again, we can use this in our previous example to measure the performance of the PixelCounter class. You can simply add the following line to the end of the testPixelCount function:
QBENCHMARK
{
c.countPixels(filename);
}
If you run the test again, you'll see outputs similar to the following in the test log output. Note that the numbers ...