Fix error in XML and Xunit formatted benchmark output.

The number of iterations was not respected for XML output, unlike for
plain text output. With this fix, benchmarks report the same result
for plain text and XML formatted output.
Compare the change to qplaintextlogger.cpp:274.

Change-Id: Ieb3e5812e18d93c36847bef0417f779efd300f86
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Daniel Molkentin <daniel@molkentin.de>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
This commit is contained in:
Mirko Boehm (AWS) 2013-03-03 13:28:19 +01:00 committed by The Qt Project
parent 04770e5824
commit 4824c74b34
2 changed files with 5 additions and 2 deletions

View File

@ -246,12 +246,13 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
benchmarkMetricName(result.metric));
xmlQuote(&quotedTag, result.context.tag.toUtf8().constData());
const qreal valuePerIteration = qreal(result.value) / qreal(result.iterations);
QTest::qt_asprintf(
&buf,
QTest::benchmarkResultFormatString(),
quotedMetric.constData(),
quotedTag.constData(),
QByteArray::number(result.value).constData(), //no 64-bit qsnprintf support
QByteArray::number(valuePerIteration).constData(), //no 64-bit qsnprintf support
result.iterations);
outputString(buf.constData());
}

View File

@ -232,7 +232,9 @@ void QXunitTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
QTest::AI_Metric,
QTest::benchmarkMetricName(QBenchmarkTestMethodData::current->result.metric));
benchmarkElement->addAttribute(QTest::AI_Tag, result.context.tag.toUtf8().data());
benchmarkElement->addAttribute(QTest::AI_Value, QByteArray::number(result.value).constData());
const qreal valuePerIteration = qreal(result.value) / qreal(result.iterations);
benchmarkElement->addAttribute(QTest::AI_Value, QByteArray::number(valuePerIteration).constData());
char buf[100];
qsnprintf(buf, sizeof(buf), "%i", result.iterations);