Use %.6g rather than %s and QByteArray::number()
The comment against the use of this claimed qvsnprintf() lacks 64-bit support, which is probably untrue by now but certainly irrelevant as the value being formatted is a qreal, not a 64-bit integral type. Since %g wants a double, make the value passed explicitly double by casting its denominator. Casting its numerator to qreal was superfluous as that's its type already. Change-Id: I5ff885fbeb9b638b2b0507061e0a19e3b8522143 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
09fd398959
commit
f8a5bb3c32
@ -198,7 +198,7 @@ static const char *incidentFormatString(bool noDescription, bool noTag)
|
||||
|
||||
static const char *benchmarkResultFormatString()
|
||||
{
|
||||
return "<BenchmarkResult metric=\"%s\" tag=\"%s\" value=\"%s\" iterations=\"%d\" />\n";
|
||||
return "<BenchmarkResult metric=\"%s\" tag=\"%s\" value=\"%.6g\" iterations=\"%d\" />\n";
|
||||
}
|
||||
|
||||
static const char *messageFormatString(bool noDescription, bool noTag)
|
||||
@ -266,13 +266,12 @@ 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(valuePerIteration).constData(), //no 64-bit qsnprintf support
|
||||
result.value / double(result.iterations),
|
||||
result.iterations);
|
||||
outputString(buf.constData());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user