I am writing some unit tests using QTest in Qt. I also came across a QBENCHMARK macro that compares the code that it encapsulates.
I run my unit tests and compare some of the code. QBENCHMARK reports how long it took to execute a method, and this is normal. I want to use runtime in unit test with, for example, QVERIFY2 (). How can i do this?
EDIT:
I am currently doing the following:
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); } }
source share