diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-09-30 12:52:15 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-10-01 19:24:31 +0200 |
commit | f8a5bb3c3213d03c12093998752c22cf67d5501c (patch) | |
tree | 2c4ad59b9654b3a327858bb85db63e59da210b80 | |
parent | 09fd39895913fddcd5909d217c2718976a27f6ce (diff) |
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>
-rw-r--r-- | src/testlib/qxmltestlogger.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 716a99d80d..89c4cbb765 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -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()); } |