From 4824c74b34eff1603ece275f6dfa22c89919488f Mon Sep 17 00:00:00 2001 From: "Mirko Boehm (AWS)" Date: Sun, 3 Mar 2013 13:28:19 +0100 Subject: [PATCH] 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 Reviewed-by: Daniel Molkentin Reviewed-by: Jason McDonald --- src/testlib/qxmltestlogger.cpp | 3 ++- src/testlib/qxunittestlogger.cpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 9bc5255bf6..3f77f152b5 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -246,12 +246,13 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) benchmarkMetricName(result.metric)); xmlQuote("edTag, 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()); } diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp index bfe9de2158..0a1a5fb6f9 100644 --- a/src/testlib/qxunittestlogger.cpp +++ b/src/testlib/qxunittestlogger.cpp @@ -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);