diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-22 14:45:49 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-22 14:52:08 (GMT) |
commit | 243021f6836f156f6a982ac74404c91a1e77f23a (patch) | |
tree | 35248d36dd2ba4fc4db7ede76e57fdf758479db4 | |
parent | 32bc108172bcd5e3372667b90d3db843a17332a7 (diff) | |
download | Qt-243021f6836f156f6a982ac74404c91a1e77f23a.zip Qt-243021f6836f156f6a982ac74404c91a1e77f23a.tar.gz Qt-243021f6836f156f6a982ac74404c91a1e77f23a.tar.bz2 |
Revert "Add a feature to QTestLib to correct benchmark results."
This reverts commit 3cc83349d9a07bcb7ae9c338bfdc355905a5a2f1.
-rw-r--r-- | src/testlib/qabstracttestlogger_p.h | 2 | ||||
-rw-r--r-- | src/testlib/qbenchmark.cpp | 6 | ||||
-rw-r--r-- | src/testlib/qbenchmark_p.h | 2 | ||||
-rw-r--r-- | src/testlib/qbenchmarkmetric.cpp | 3 | ||||
-rw-r--r-- | src/testlib/qbenchmarkmetric.h | 3 | ||||
-rw-r--r-- | src/testlib/qplaintestlogger.cpp | 45 | ||||
-rw-r--r-- | src/testlib/qplaintestlogger_p.h | 2 | ||||
-rw-r--r-- | src/testlib/qtest_global.h | 9 | ||||
-rw-r--r-- | src/testlib/qtestcase.cpp | 22 | ||||
-rw-r--r-- | src/testlib/qtestcase.h | 2 | ||||
-rw-r--r-- | src/testlib/qtestdata.cpp | 20 | ||||
-rw-r--r-- | src/testlib/qtestdata.h | 2 | ||||
-rw-r--r-- | src/testlib/qtestlog.cpp | 33 | ||||
-rw-r--r-- | src/testlib/qtestlog_p.h | 2 | ||||
-rw-r--r-- | src/testlib/qtestlogger.cpp | 2 | ||||
-rw-r--r-- | src/testlib/qtestlogger_p.h | 2 | ||||
-rw-r--r-- | src/testlib/qtesttable.cpp | 4 | ||||
-rw-r--r-- | src/testlib/qtesttable_p.h | 2 | ||||
-rw-r--r-- | src/testlib/qxmltestlogger.cpp | 2 | ||||
-rw-r--r-- | src/testlib/qxmltestlogger_p.h | 2 |
20 files changed, 33 insertions, 134 deletions
diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index 50f651a..d116a6e 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -90,7 +90,7 @@ public: virtual void addIncident(IncidentTypes type, const char *description, const char *file = 0, int line = 0) = 0; - virtual void addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &correctedResult) = 0; + virtual void addBenchmarkResult(const QBenchmarkResult &result) = 0; virtual void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0) = 0; diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index cb56154..d933fb1 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -181,12 +181,6 @@ void QBenchmarkTestMethodData::setResult( QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro); } -void QBenchmarkTestMethodData::clearSpecialResults() -{ - for (int i = 0; i < QTest::BenchmarkSpecialCount; ++i) - specialResults[i] = QBenchmarkResult(); -} - /*! \class QTest::QBenchmarkIterationController \internal diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index 387ad8b..ace17db 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -177,10 +177,8 @@ public: bool resultsAccepted() const { return resultAccepted; } int adjustIterationCount(int suggestion); void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true); - void clearSpecialResults(); QBenchmarkResult result; - QBenchmarkResult specialResults[QTest::BenchmarkSpecialCount]; bool resultAccepted; bool runOnce; int iterationCount; diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp index 1631e98..025bf46 100644 --- a/src/testlib/qbenchmarkmetric.cpp +++ b/src/testlib/qbenchmarkmetric.cpp @@ -81,8 +81,6 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric) return "InstructionReads"; case Events: return "Events"; - case Percentage: - return "Percentage"; default: return ""; } @@ -110,7 +108,6 @@ const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric) return "instruction reads"; case Events: return "events"; - case Percentage: default: return ""; } diff --git a/src/testlib/qbenchmarkmetric.h b/src/testlib/qbenchmarkmetric.h index a413108..c8ab2fd 100644 --- a/src/testlib/qbenchmarkmetric.h +++ b/src/testlib/qbenchmarkmetric.h @@ -59,8 +59,7 @@ enum QBenchmarkMetric { WalltimeMilliseconds, CPUTicks, InstructionReads, - Events, - Percentage + Events }; } diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index c5c6fd6..e1ae534 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -315,7 +315,7 @@ namespace QTest { } // static void printBenchmarkResult(const char *bmtag, int value, int iterations) - static void printBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &corrected) + static void printBenchmarkResult(const QBenchmarkResult &result) { const char *bmtag = QTest::benchmarkResult2String(); @@ -333,6 +333,7 @@ namespace QTest { QTest::qt_snprintf(bufTag, sizeof(bufTag), ":\"%s\"", tag.data()); } + char fillFormat[8]; int fillLength = 5; QTest::qt_snprintf( @@ -340,30 +341,6 @@ namespace QTest { char fill[1024]; QTest::qt_snprintf(fill, sizeof(fill), fillFormat, ""); - char buf1_[1024]; - buf1_[0] = 0; - if (corrected.valid) { - if (corrected.metric == QTest::Percentage) { - if (corrected.value <= 3 && corrected.value >= -1) - QTest::qt_snprintf( - buf1_, sizeof(buf1_), "%.1f%% (of baseline), actual: ", corrected.value * 100); - else - QTest::qt_snprintf( - buf1_, sizeof(buf1_), "%.2fx (of baseline), actual: ", corrected.value); - } else { - const char * unitText = QTest::benchmarkMetricUnit(corrected.metric); - - qreal valuePerIteration = qreal(corrected.value) / qreal(corrected.iterations); - char resultBuffer[100] = ""; - formatResult(resultBuffer, 100, valuePerIteration, countSignificantDigits(corrected.value)); - - QTest::qt_snprintf( - buf1_, sizeof(buf1_), "%s %s (corrected), actual: ", - resultBuffer, - unitText); - } - } - const char * unitText = QTest::benchmarkMetricUnit(result.metric); qreal valuePerIteration = qreal(result.value) / qreal(result.iterations); @@ -372,10 +349,18 @@ namespace QTest { char buf2[1024]; QTest::qt_snprintf( - buf2, sizeof(buf2), "%s %s per iteration", + buf2, sizeof(buf2), "%s %s", resultBuffer, unitText); + char buf2_[1024]; + QByteArray iterationText = " per iteration"; + Q_ASSERT(result.iterations > 0); + QTest::qt_snprintf( + buf2_, + sizeof(buf2_), "%s", + iterationText.data()); + char buf3[1024]; Q_ASSERT(result.iterations > 0); formatResult(resultBuffer, 100, result.value, countSignificantDigits(result.value)); @@ -388,9 +373,9 @@ namespace QTest { if (result.setByMacro) { QTest::qt_snprintf( - buf, sizeof(buf), "%s%s%s%s%s%s\n", buf1, bufTag, fill, buf1_, buf2, buf3); + buf, sizeof(buf), "%s%s%s%s%s%s\n", buf1, bufTag, fill, buf2, buf2_, buf3); } else { - QTest::qt_snprintf(buf, sizeof(buf), "%s%s%s%s%s\n", buf1, bufTag, fill, buf1_, buf2); + QTest::qt_snprintf(buf, sizeof(buf), "%s%s%s%s\n", buf1, bufTag, fill, buf2); } memcpy(buf, bmtag, strlen(bmtag)); @@ -486,10 +471,10 @@ void QPlainTestLogger::addIncident(IncidentTypes type, const char *description, QTest::printMessage(QTest::incidentType2String(type), description, file, line); } -void QPlainTestLogger::addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &corrected) +void QPlainTestLogger::addBenchmarkResult(const QBenchmarkResult &result) { // QTest::printBenchmarkResult(QTest::benchmarkResult2String(), value, iterations); - QTest::printBenchmarkResult(result, corrected); + QTest::printBenchmarkResult(result); } void QPlainTestLogger::addMessage(MessageTypes type, const char *message, diff --git a/src/testlib/qplaintestlogger_p.h b/src/testlib/qplaintestlogger_p.h index c5165dd..054ec1e 100644 --- a/src/testlib/qplaintestlogger_p.h +++ b/src/testlib/qplaintestlogger_p.h @@ -71,7 +71,7 @@ public: void addIncident(IncidentTypes type, const char *description, const char *file = 0, int line = 0); - void addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &corrected); + void addBenchmarkResult(const QBenchmarkResult &result); void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h index 2e7217c..28c8617 100644 --- a/src/testlib/qtest_global.h +++ b/src/testlib/qtest_global.h @@ -81,15 +81,6 @@ namespace QTest { enum SkipMode { SkipSingle = 1, SkipAll = 2 }; enum TestFailMode { Abort = 1, Continue = 2 }; - enum BenchmarkDataMode { - Normal = -1, - Zero = 0, - Subtract = Zero, - Baseline, - Divide = Baseline, - - BenchmarkSpecialCount = 2 - }; int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format, ...); } diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 698d9b5..287d8e6 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1384,17 +1384,8 @@ static void qInvokeTestMethodDataEntry(char *slot) && (++i < QBenchmarkGlobalData::current->adjustMedianIterationCount())); if (QBenchmarkTestMethodData::current->isBenchmark() - && QBenchmarkTestMethodData::current->resultsAccepted()) { - QBenchmarkResult result = qMedian(results); - - QBenchmarkResult *specialResults = QBenchmarkTestMethodData::current->specialResults; - if (QTestResult::currentTestData()) { - QTest::BenchmarkDataMode benchMode = QTestResult::currentTestData()->benchmarkSpecialData(); - if (benchMode > QTest::Normal && benchMode < QTest::BenchmarkSpecialCount) - specialResults[benchMode] = result; - } - QTestLog::addBenchmarkResult(result, specialResults); - } + && QBenchmarkTestMethodData::current->resultsAccepted()) + QTestLog::addBenchmarkResult(qMedian(results)); } /*! @@ -1462,8 +1453,6 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0) } } - benchmarkData.clearSpecialResults(); - /* For each entry in the data table, do: */ do { if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) { @@ -2049,15 +2038,10 @@ void QTest::addColumnInternal(int id, const char *name) */ QTestData &QTest::newRow(const char *dataTag) { - return newRow(dataTag, Normal); -} - -QTestData &QTest::newRow(const char *dataTag, BenchmarkDataMode mode) -{ QTestTable *tbl = QTestTable::currentTestTable(); QTEST_ASSERT_X(tbl, "QTest::addColumn()", "Cannot add testdata outside of a _data slot."); - return *tbl->newData(dataTag, mode); + return *tbl->newData(dataTag); } /*! \fn void QTest::addColumn(const char *name, T *dummy = 0) diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index c0787a8..a2cc26d 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -125,6 +125,7 @@ namespace QTest return 0; } + Q_TESTLIB_EXPORT char *toHexRepresentation(const char *ba, int length); Q_TESTLIB_EXPORT char *toString(const char *); Q_TESTLIB_EXPORT char *toString(const void *); @@ -167,7 +168,6 @@ namespace QTest addColumnInternal(qMetaTypeId<T>(), name); } Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag); - Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag, BenchmarkDataMode mode); template <typename T> inline bool qCompare(T const &t1, T const &t2, const char *actual, const char *expected, diff --git a/src/testlib/qtestdata.cpp b/src/testlib/qtestdata.cpp index c22dbe2..588ad64 100644 --- a/src/testlib/qtestdata.cpp +++ b/src/testlib/qtestdata.cpp @@ -53,13 +53,12 @@ QT_BEGIN_NAMESPACE class QTestDataPrivate { public: - QTestDataPrivate(): tag(0), parent(0), data(0), dataCount(0), benchmarkDataMode(QTest::Normal) {} + QTestDataPrivate(): tag(0), parent(0), data(0), dataCount(0) {} char *tag; QTestTable *parent; void **data; int dataCount; - QTest::BenchmarkDataMode benchmarkDataMode; }; QTestData::QTestData(const char *tag, QTestTable *parent) @@ -73,18 +72,6 @@ QTestData::QTestData(const char *tag, QTestTable *parent) memset(d->data, 0, parent->elementCount() * sizeof(void*)); } -QTestData::QTestData(const char *tag, QTest::BenchmarkDataMode benchMode, QTestTable *parent) -{ - QTEST_ASSERT(tag); - QTEST_ASSERT(parent); - d = new QTestDataPrivate; - d->tag = qstrdup(tag); - d->parent = parent; - d->data = new void *[parent->elementCount()]; - d->benchmarkDataMode = benchMode; - memset(d->data, 0, parent->elementCount() * sizeof(void*)); -} - QTestData::~QTestData() { for (int i = 0; i < d->dataCount; ++i) { @@ -132,9 +119,4 @@ int QTestData::dataCount() const return d->dataCount; } -QTest::BenchmarkDataMode QTestData::benchmarkSpecialData() const -{ - return d->benchmarkDataMode; -} - QT_END_NAMESPACE diff --git a/src/testlib/qtestdata.h b/src/testlib/qtestdata.h index f154b8f..b39bce2 100644 --- a/src/testlib/qtestdata.h +++ b/src/testlib/qtestdata.h @@ -66,12 +66,10 @@ public: const char *dataTag() const; QTestTable *parent() const; int dataCount() const; - QTest::BenchmarkDataMode benchmarkSpecialData() const; private: friend class QTestTable; QTestData(const char *tag = 0, QTestTable *parent = 0); - QTestData(const char *tag, QTest::BenchmarkDataMode mode, QTestTable *parent = 0); Q_DISABLE_COPY(QTestData) diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 28358be..ed9a005 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -46,7 +46,6 @@ #include "QtTest/private/qabstracttestlogger_p.h" #include "QtTest/private/qplaintestlogger_p.h" #include "QtTest/private/qxmltestlogger_p.h" -#include "QtTest/private/qbenchmark_p.h" #include <QtCore/qatomic.h> #include <QtCore/qbytearray.h> @@ -286,38 +285,10 @@ void QTestLog::addSkip(const char *msg, QTest::SkipMode /*mode*/, QTest::testLogger->addMessage(QAbstractTestLogger::Skip, msg, file, line); } -void QTestLog::addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult *specialResults) +void QTestLog::addBenchmarkResult(const QBenchmarkResult &result) { QTEST_ASSERT(QTest::testLogger); - QTEST_ASSERT(specialResults); - - QBenchmarkResult corrected; - const QBenchmarkResult &zero = specialResults[QTest::Zero]; - if (zero.valid && zero.metric == result.metric) { - // subtract the zero result - corrected = result; - if (zero.iterations == corrected.iterations) - corrected.value -= zero.value; - else - corrected.value -= zero.value / zero.iterations * corrected.iterations; - } - - const QBenchmarkResult &baseline = specialResults[QTest::Baseline]; - if (baseline.valid && baseline.metric == result.metric) { - // divide by the baseline - if (!corrected.valid) - corrected = result; - corrected.value /= corrected.iterations; - corrected.iterations = 1; - corrected.metric = QTest::Percentage; - - qreal subtract = 0; - if (zero.valid && zero.metric == baseline.metric) - subtract = zero.value / zero.iterations; - corrected.value /= baseline.value / baseline.iterations - subtract; - } - - QTest::testLogger->addBenchmarkResult(result, corrected); + QTest::testLogger->addBenchmarkResult(result); } void QTestLog::startLogging(unsigned int randomSeed) diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h index 02c0dd9..a892d3d 100644 --- a/src/testlib/qtestlog_p.h +++ b/src/testlib/qtestlog_p.h @@ -74,7 +74,7 @@ public: static void addXPass(const char *msg, const char *file, int line); static void addSkip(const char *msg, QTest::SkipMode mode, const char *file, int line); - static void addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult *specialResults); + static void addBenchmarkResult(const QBenchmarkResult &result); static void addIgnoreMessage(QtMsgType type, const char *msg); static int unhandledIgnoreMessages(); static void printUnhandledIgnoreMessages(); diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index 3962b09..86826f8 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -268,7 +268,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description, } } -void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &) +void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result) { QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark); // printf("element %i", benchmarkElement->elementType()); diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h index 3dc8640..d8867de 100644 --- a/src/testlib/qtestlogger_p.h +++ b/src/testlib/qtestlogger_p.h @@ -82,7 +82,7 @@ class QTestLogger : public QAbstractTestLogger void addIncident(IncidentTypes type, const char *description, const char *file = 0, int line = 0); - void addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &correctedResult); + void addBenchmarkResult(const QBenchmarkResult &result); void addTag(QTestElement* element); void addMessage(MessageTypes type, const char *message, diff --git a/src/testlib/qtesttable.cpp b/src/testlib/qtesttable.cpp index 7c5acce..df10462 100644 --- a/src/testlib/qtesttable.cpp +++ b/src/testlib/qtesttable.cpp @@ -190,9 +190,9 @@ bool QTestTable::isEmpty() const return !d->list; } -QTestData *QTestTable::newData(const char *tag, QTest::BenchmarkDataMode benchMode) +QTestData *QTestTable::newData(const char *tag) { - QTestData *dt = new QTestData(tag, benchMode, this); + QTestData *dt = new QTestData(tag, this); d->append(dt); return dt; } diff --git a/src/testlib/qtesttable_p.h b/src/testlib/qtesttable_p.h index b85e9aa..f835506 100644 --- a/src/testlib/qtesttable_p.h +++ b/src/testlib/qtesttable_p.h @@ -67,7 +67,7 @@ public: ~QTestTable(); void addColumn(int elementType, const char *elementName); - QTestData *newData(const char *tag, QTest::BenchmarkDataMode benchMode); + QTestData *newData(const char *tag); int elementCount() const; int dataCount() const; diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 3edd687..827b0ad 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -246,7 +246,7 @@ void QXmlTestLogger::addIncident(IncidentTypes type, const char *description, outputString(buf.constData()); } -void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &) +void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) { QTestCharBuffer buf; QTestCharBuffer quotedMetric; diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index adfe98b..f815103 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -74,7 +74,7 @@ public: void addIncident(IncidentTypes type, const char *description, const char *file = 0, int line = 0); - void addBenchmarkResult(const QBenchmarkResult &result, const QBenchmarkResult &corrected); + void addBenchmarkResult(const QBenchmarkResult &result); void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); |