I am writing some unit tests using QTest in Qt. I also encountered the QBENCHMARK macro, which benchmarks the code it encapsulates.
I am running my unit tests and benchmarks some of the code. The QBENCHMARK reports how long it took to execute some method and that is fine. I want to use the execution time in a unit test with for example QVERIFY2(). How can I do this?
EDIT:
What I am currently doing is:
void UnitTest::benchmark()
{
QString str1 = QLatin1String("This is a test string");
QString str2 = QLatin1String("This is a test string");
QCOMPARE(str1.localeAwareCompare(str2), 0);
QBENCHMARK {
str1.localeAwareCompare(str2);
}
}