From b88141c7505e10ffaa25cc20b444da8e2cc6d9c7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 15:30:06 +0100 Subject: BenchLib: update the result format and self-test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since BenchLib now uses floating point for its calculations, we should format both the value per-iteration and the total the same way. Otherwise, it would output something like "2e+08" for the total. Reviewed-by: Morten Sørvig --- src/testlib/qplaintestlogger.cpp | 3 ++- tests/auto/selftests/expected_benchlibcallgrind.txt | 2 +- tests/auto/selftests/tst_selftests.cpp | 13 ++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index e244690..46431a8 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -362,9 +362,10 @@ namespace QTest { char buf3[1024]; Q_ASSERT(result.iterations > 0); + formatResult(resultBuffer, 100, result.value, countSignificantDigits(result.value)); QTest::qt_snprintf( buf3, sizeof(buf3), " (total: %s, iterations: %d)", - QByteArray::number(result.value).constData(), // no 64-bit qt_snprintf support + resultBuffer, result.iterations); char buf[1024]; diff --git a/tests/auto/selftests/expected_benchlibcallgrind.txt b/tests/auto/selftests/expected_benchlibcallgrind.txt index caf2424..f172711 100644 --- a/tests/auto/selftests/expected_benchlibcallgrind.txt +++ b/tests/auto/selftests/expected_benchlibcallgrind.txt @@ -2,7 +2,7 @@ Config: Using QTest library 4.5.0, Qt 4.5.0 PASS : tst_BenchlibCallgrind::initTestCase() RESULT : tst_BenchlibCallgrind::twoHundredMillionInstructions(): - 200,000,000 instr. loads per iteration (total: 200000000, iterations: 1) + 200,000,000 instruction reads per iteration (total: 200000000, iterations: 1) PASS : tst_BenchlibCallgrind::twoHundredMillionInstructions() PASS : tst_BenchlibCallgrind::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 89ece0f..6608439 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -97,7 +97,7 @@ inline bool qCompare if (r1.unit == "msec") { variance = 0.1; } - else if (r1.unit == "instr. loads") { + else if (r1.unit == "instruction reads") { variance = 0.001; } else if (r1.unit == "ticks") { @@ -434,7 +434,7 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) /* This code avoids using a QRegExp because QRegExp might be broken. */ - /* Sample format: 4,000 msec per iteration (total: 4000, iterations: 1) */ + /* Sample format: 4,000 msec per iteration (total: 4,000, iterations: 1) */ QString sFirstNumber; while (!remaining.isEmpty() && !remaining.at(0).isSpace()) { @@ -468,7 +468,7 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) remaining = remaining.mid(sizeof(periterbit)-1); - /* Remaining: 4000, iterations: 1) */ + /* Remaining: 4,000, iterations: 1) */ static const char itersbit[] = ", iterations: "; QString sTotal; while (!remaining.startsWith(itersbit) && !remaining.isEmpty()) { @@ -482,9 +482,12 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) remaining = remaining.mid(sizeof(itersbit)-1); - qint64 total = sTotal.toLongLong(&ok); + /* 4,000 -> 4000 */ + sTotal.remove(','); + + double total = sTotal.toDouble(&ok); if (!ok) { - if (error) *error = sTotal + " (total) is not a valid integer"; + if (error) *error = sTotal + " (total) is not a valid number"; return out; } -- cgit v0.12