remove unused and redundant test module methods

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2020-08-15 16:11:20 +03:00
parent 27293db2e4
commit 43bcdcfce3
8 changed files with 20 additions and 156 deletions

View file

@ -52,8 +52,7 @@ QBenchmarkGlobalData::QBenchmarkGlobalData()
: measurer(0)
, walltimeMinimum(-1)
, iterationCount(-1)
, medianIterationCount(-1)
, createChart(false)
, medianIterationCount(1)
, verboseOutput(false)
, mode_(WallTime)
{
@ -72,36 +71,25 @@ void QBenchmarkGlobalData::setMode(Mode mode)
if (measurer)
delete measurer;
measurer = createMeasurer();
}
QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer()
{
QBenchmarkMeasurerBase *m = 0;
if (0) {
if (mode_ == EventCounter) {
measurer = new QBenchmarkEvent;
#ifdef QTESTLIB_USE_VALGRIND
} else if (mode_ == CallgrindChildProcess || mode_ == CallgrindParentProcess) {
m = new QBenchmarkCallgrindMeasurer;
measurer = new QBenchmarkCallgrindMeasurer;
#endif
#ifdef HAVE_TICK_COUNTER
} else if (mode_ == TickCounter) {
m = new QBenchmarkTickMeasurer;
measurer = new QBenchmarkTickMeasurer;
#endif
} else if (mode_ == EventCounter) {
m = new QBenchmarkEvent;
} else {
m = new QBenchmarkTimeMeasurer;
measurer = new QBenchmarkTimeMeasurer;
}
return m;
}
int QBenchmarkGlobalData::adjustMedianIterationCount()
{
if (medianIterationCount != -1) {
return medianIterationCount;
} else {
return measurer->adjustMedianCount(1);
}
return medianIterationCount;
}
@ -120,7 +108,12 @@ QBenchmarkTestMethodData::~QBenchmarkTestMethodData()
void QBenchmarkTestMethodData::beginDataRun()
{
iterationCount = adjustIterationCount(1);
// Let the -iterations option override the measurer.
if (QBenchmarkGlobalData::current->iterationCount != -1) {
iterationCount = QBenchmarkGlobalData::current->iterationCount;
} else {
iterationCount = 1;
}
}
void QBenchmarkTestMethodData::endDataRun()
@ -128,18 +121,6 @@ void QBenchmarkTestMethodData::endDataRun()
}
int QBenchmarkTestMethodData::adjustIterationCount(int suggestion)
{
// Let the -iterations option override the measurer.
if (QBenchmarkGlobalData::current->iterationCount != -1) {
iterationCount = QBenchmarkGlobalData::current->iterationCount;
} else {
iterationCount = QBenchmarkGlobalData::current->measurer->adjustIterationCount(suggestion);
}
return iterationCount;
}
void QBenchmarkTestMethodData::setResult(
qreal value, QTest::QBenchmarkMetric metric, bool setByMacro)
{
@ -188,20 +169,23 @@ QTest::QBenchmarkIterationController::QBenchmarkIterationController(RunMode runM
i = 0;
if (runMode == RunOnce)
QBenchmarkTestMethodData::current->runOnce = true;
QTest::beginBenchmarkMeasurement();
QBenchmarkGlobalData::current->measurer->start();
// the clock is ticking after the line above, don't add code here.
}
QTest::QBenchmarkIterationController::QBenchmarkIterationController()
{
i = 0;
QTest::beginBenchmarkMeasurement();
QBenchmarkGlobalData::current->measurer->start();
// the clock is ticking after the line above, don't add code here.
}
/*! \internal
*/
QTest::QBenchmarkIterationController::~QBenchmarkIterationController()
{
const qreal result = QTest::endBenchmarkMeasurement();
// the clock is ticking before the line below, don't add code here.
const qreal result = QBenchmarkGlobalData::current->measurer->stop();
QBenchmarkTestMethodData::current->setResult(result, QBenchmarkGlobalData::current->measurer->metricType());
}
@ -211,7 +195,7 @@ bool QTest::QBenchmarkIterationController::isDone()
{
if (QBenchmarkTestMethodData::current->runOnce)
return i > 0;
return i >= QTest::iterationCount();
return i >= QBenchmarkTestMethodData::current->iterationCount;
}
/*! \internal
@ -221,44 +205,6 @@ void QTest::QBenchmarkIterationController::next()
++i;
}
/*! \internal
*/
int QTest::iterationCount()
{
return QBenchmarkTestMethodData::current->iterationCount;
}
/*! \internal
*/
void QTest::setIterationCountHint(int count)
{
QBenchmarkTestMethodData::current->adjustIterationCount(count);
}
/*! \internal
*/
void QTest::setIterationCount(int count)
{
QBenchmarkTestMethodData::current->iterationCount = count;
QBenchmarkTestMethodData::current->resultAccepted = true;
}
/*! \internal
*/
void QTest::beginBenchmarkMeasurement()
{
QBenchmarkGlobalData::current->measurer->start();
// the clock is ticking after the line above, don't add code here.
}
/*! \internal
*/
quint64 QTest::endBenchmarkMeasurement()
{
// the clock is ticking before the line below, don't add code here.
return QBenchmarkGlobalData::current->measurer->stop();
}
/*!
Sets the benchmark result for this test function to \a result.
@ -281,19 +227,4 @@ void QTest::setBenchmarkResult(qreal result, QTest::QBenchmarkMetric metric)
QBenchmarkTestMethodData::current->setResult(result, metric, false);
}
template <typename T>
Q_TYPENAME T::value_type qAverage(const T &container)
{
Q_TYPENAME T::const_iterator it = container.constBegin();
Q_TYPENAME T::const_iterator end = container.constEnd();
Q_TYPENAME T::value_type acc = Q_TYPENAME T::value_type();
int count = 0;
while (it != end) {
acc += *it;
++it;
++count;
}
return acc / count;
}
QT_END_NAMESPACE

View file

@ -123,7 +123,6 @@ public:
enum Mode { WallTime, CallgrindParentProcess, CallgrindChildProcess, TickCounter, EventCounter };
void setMode(Mode mode);
Mode mode() const { return mode_; }
QBenchmarkMeasurerBase *createMeasurer();
int adjustMedianIterationCount();
QBenchmarkMeasurerBase *measurer;
@ -131,7 +130,6 @@ public:
int walltimeMinimum;
int iterationCount;
int medianIterationCount;
bool createChart;
bool verboseOutput;
QString callgrindOutFileBase;
private:
@ -158,7 +156,6 @@ public:
bool isBenchmark() const { return result.valid; }
bool resultsAccepted() const { return resultAccepted; }
int adjustIterationCount(int suggestion);
void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true);
QBenchmarkResult result;
@ -167,17 +164,6 @@ public:
int iterationCount;
};
// low-level API:
namespace QTest
{
int iterationCount();
void setIterationCountHint(int count);
void setIterationCount(int count);
Q_TEST_EXPORT void beginBenchmarkMeasurement();
Q_TEST_EXPORT quint64 endBenchmarkMeasurement();
}
QT_END_NAMESPACE
#endif // QBENCHMARK_H

View file

@ -73,17 +73,6 @@ bool QBenchmarkEvent::isMeasurementAccepted(qint64 measurement)
return true;
}
int QBenchmarkEvent::adjustIterationCount(int suggestion)
{
return suggestion;
}
int QBenchmarkEvent::adjustMedianCount(int suggestion)
{
Q_UNUSED(suggestion);
return 1;
}
QTest::QBenchmarkMetric QBenchmarkEvent::metricType()
{
return QTest::Events;

View file

@ -59,9 +59,6 @@ public:
qint64 checkpoint();
qint64 stop();
bool isMeasurementAccepted(qint64 measurement);
int adjustIterationCount(int suggestion);
int adjustMedianCount(int suggestion);
bool repeatCount() { return 1; }
QTest::QBenchmarkMetric metricType();
static bool eventCountingMechanism(void *message);
static qint64 eventCounter;

View file

@ -62,21 +62,11 @@ bool QBenchmarkTimeMeasurer::isMeasurementAccepted(qint64 measurement)
return (measurement > 50);
}
int QBenchmarkTimeMeasurer::adjustIterationCount(int suggestion)
{
return suggestion;
}
bool QBenchmarkTimeMeasurer::needsWarmupIteration()
{
return true;
}
int QBenchmarkTimeMeasurer::adjustMedianCount(int)
{
return 1;
}
QTest::QBenchmarkMetric QBenchmarkTimeMeasurer::metricType()
{
return QTest::WalltimeMilliseconds;
@ -106,16 +96,6 @@ bool QBenchmarkTickMeasurer::isMeasurementAccepted(qint64)
return true;
}
int QBenchmarkTickMeasurer::adjustIterationCount(int)
{
return 1;
}
int QBenchmarkTickMeasurer::adjustMedianCount(int)
{
return 1;
}
bool QBenchmarkTickMeasurer::needsWarmupIteration()
{
return true;

View file

@ -59,9 +59,6 @@ public:
virtual qint64 checkpoint() = 0;
virtual qint64 stop() = 0;
virtual bool isMeasurementAccepted(qint64 measurement) = 0;
virtual int adjustIterationCount(int suggestion) = 0;
virtual int adjustMedianCount(int suggestion) = 0;
virtual bool repeatCount() { return 1; }
virtual bool needsWarmupIteration() { return false; }
virtual QTest::QBenchmarkMetric metricType() = 0;
};
@ -73,8 +70,6 @@ public:
qint64 checkpoint();
qint64 stop();
bool isMeasurementAccepted(qint64 measurement);
int adjustIterationCount(int sugestion);
int adjustMedianCount(int suggestion);
bool needsWarmupIteration();
QTest::QBenchmarkMetric metricType();
private:
@ -90,8 +85,6 @@ public:
qint64 checkpoint();
qint64 stop();
bool isMeasurementAccepted(qint64 measurement);
int adjustIterationCount(int);
int adjustMedianCount(int suggestion);
bool needsWarmupIteration();
QTest::QBenchmarkMetric metricType();
private:

View file

@ -234,16 +234,6 @@ bool QBenchmarkCallgrindMeasurer::isMeasurementAccepted(qint64 measurement)
return true;
}
int QBenchmarkCallgrindMeasurer::adjustIterationCount(int)
{
return 1;
}
int QBenchmarkCallgrindMeasurer::adjustMedianCount(int)
{
return 1;
}
bool QBenchmarkCallgrindMeasurer::needsWarmupIteration()
{
return true;

View file

@ -74,8 +74,6 @@ public:
qint64 checkpoint();
qint64 stop();
bool isMeasurementAccepted(qint64 measurement);
int adjustIterationCount(int);
int adjustMedianCount(int);
bool needsWarmupIteration();
QTest::QBenchmarkMetric metricType();
};