| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/testlib/qbenchmark.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | QBenchmarkGlobalData *QBenchmarkGlobalData::current; | - | ||||||||||||
| 6 | - | |||||||||||||
| 7 | QBenchmarkGlobalData::QBenchmarkGlobalData() | - | ||||||||||||
| 8 | : measurer(0) | - | ||||||||||||
| 9 | , walltimeMinimum(-1) | - | ||||||||||||
| 10 | , iterationCount(-1) | - | ||||||||||||
| 11 | , medianIterationCount(-1) | - | ||||||||||||
| 12 | , createChart(false) | - | ||||||||||||
| 13 | , verboseOutput(false) | - | ||||||||||||
| 14 | , minimumTotal(-1) | - | ||||||||||||
| 15 | , mode_(WallTime) | - | ||||||||||||
| 16 | { | - | ||||||||||||
| 17 | setMode(mode_); | - | ||||||||||||
| 18 | } executed 815 times by 1 test: end of blockExecuted by:
| 815 | ||||||||||||
| 19 | - | |||||||||||||
| 20 | QBenchmarkGlobalData::~QBenchmarkGlobalData() | - | ||||||||||||
| 21 | { | - | ||||||||||||
| 22 | delete measurer; | - | ||||||||||||
| 23 | QBenchmarkGlobalData::current = 0; | - | ||||||||||||
| 24 | } executed 1238 times by 508 tests: end of blockExecuted by:
| 1238 | ||||||||||||
| 25 | - | |||||||||||||
| 26 | void QBenchmarkGlobalData::setMode(Mode mode) | - | ||||||||||||
| 27 | { | - | ||||||||||||
| 28 | mode_ = mode; | - | ||||||||||||
| 29 | - | |||||||||||||
| 30 | if (measurer
| 73-815 | ||||||||||||
| 31 | delete measurer; executed 73 times by 1 test: delete measurer;Executed by:
| 73 | ||||||||||||
| 32 | measurer = createMeasurer(); | - | ||||||||||||
| 33 | } executed 888 times by 1 test: end of blockExecuted by:
| 888 | ||||||||||||
| 34 | - | |||||||||||||
| 35 | QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer() | - | ||||||||||||
| 36 | { | - | ||||||||||||
| 37 | QBenchmarkMeasurerBase *measurer = 0; | - | ||||||||||||
| 38 | if (0) { dead code: { } | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | } dead code: else if (mode_ == CallgrindChildProcess{ }
| - | ||||||||||||
| 41 | measurer = new QBenchmarkCallgrindMeasurer; | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | - | |||||||||||||
| 44 | } never executed: else if (mode_ == PerfCounterend of block
| 0-888 | ||||||||||||
| 45 | measurer = new QBenchmarkPerfEventsMeasurer; | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | - | |||||||||||||
| 48 | } never executed: else if (mode_ == TickCounterend of block
| 0-888 | ||||||||||||
| 49 | measurer = new QBenchmarkTickMeasurer; | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | } never executed: else if (mode_ == EventCounterend of block
| 0-815 | ||||||||||||
| 52 | measurer = new QBenchmarkEvent; | - | ||||||||||||
| 53 | } executed 73 times by 1 test: else {end of blockExecuted by:
| 73 | ||||||||||||
| 54 | measurer = new QBenchmarkTimeMeasurer; | - | ||||||||||||
| 55 | } executed 815 times by 1 test: end of blockExecuted by:
| 815 | ||||||||||||
| 56 | measurer->init(); | - | ||||||||||||
| 57 | return executed 888 times by 1 test: measurer;return measurer;Executed by:
executed 888 times by 1 test: return measurer;Executed by:
| 888 | ||||||||||||
| 58 | } | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | int QBenchmarkGlobalData::adjustMedianIterationCount() | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | if (medianIterationCount != -1
| 0-408 | ||||||||||||
| 63 | return never executed: medianIterationCount;return medianIterationCount;never executed: return medianIterationCount; | 0 | ||||||||||||
| 64 | } else { | - | ||||||||||||
| 65 | return executed 408 times by 2 tests: measurer->adjustMedianCount(1);return measurer->adjustMedianCount(1);Executed by:
executed 408 times by 2 tests: return measurer->adjustMedianCount(1);Executed by:
| 408 | ||||||||||||
| 66 | } | - | ||||||||||||
| 67 | } | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | - | |||||||||||||
| 70 | QBenchmarkTestMethodData *QBenchmarkTestMethodData::current; | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | QBenchmarkTestMethodData::QBenchmarkTestMethodData() | - | ||||||||||||
| 73 | :resultAccepted(false), runOnce(false), iterationCount(-1) | - | ||||||||||||
| 74 | { | - | ||||||||||||
| 75 | } executed 13256 times by 502 tests: end of blockExecuted by:
| 13256 | ||||||||||||
| 76 | - | |||||||||||||
| 77 | QBenchmarkTestMethodData::~QBenchmarkTestMethodData() | - | ||||||||||||
| 78 | { | - | ||||||||||||
| 79 | QBenchmarkTestMethodData::current = 0; | - | ||||||||||||
| 80 | } executed 13199 times by 502 tests: end of blockExecuted by:
| 13199 | ||||||||||||
| 81 | - | |||||||||||||
| 82 | void QBenchmarkTestMethodData::beginDataRun() | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | iterationCount = adjustIterationCount(1); | - | ||||||||||||
| 85 | } executed 126618 times by 502 tests: end of blockExecuted by:
| 126618 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | void QBenchmarkTestMethodData::endDataRun() | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | int QBenchmarkTestMethodData::adjustIterationCount(int suggestion) | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | if (QBenchmarkGlobalData::current->iterationCount != -1
| 240-126378 | ||||||||||||
| 95 | iterationCount = QBenchmarkGlobalData::current->iterationCount; | - | ||||||||||||
| 96 | } executed 240 times by 1 test: else {end of blockExecuted by:
| 240 | ||||||||||||
| 97 | iterationCount = QBenchmarkGlobalData::current->measurer->adjustIterationCount(suggestion); | - | ||||||||||||
| 98 | } executed 126378 times by 502 tests: end of blockExecuted by:
| 126378 | ||||||||||||
| 99 | - | |||||||||||||
| 100 | return executed 126618 times by 502 tests: iterationCount;return iterationCount;Executed by:
executed 126618 times by 502 tests: return iterationCount;Executed by:
| 126618 | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | void QBenchmarkTestMethodData::setResult( | - | ||||||||||||
| 104 | qreal value, QTest::QBenchmarkMetric metric, bool setByMacro) | - | ||||||||||||
| 105 | { | - | ||||||||||||
| 106 | bool accepted = false; | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | - | |||||||||||||
| 109 | - | |||||||||||||
| 110 | if (QBenchmarkGlobalData::current->iterationCount != -1
| 138-282 | ||||||||||||
| 111 | accepted = true; executed 138 times by 1 test: accepted = true;Executed by:
| 138 | ||||||||||||
| 112 | - | |||||||||||||
| 113 | else if (QBenchmarkTestMethodData::current->runOnce
| 0-266 | ||||||||||||
| 114 | iterationCount = 1; | - | ||||||||||||
| 115 | accepted = true; | - | ||||||||||||
| 116 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||
| 117 | - | |||||||||||||
| 118 | - | |||||||||||||
| 119 | - | |||||||||||||
| 120 | else if (QBenchmarkGlobalData::current->walltimeMinimum != -1
| 14-252 | ||||||||||||
| 121 | accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum); executed 14 times by 1 test: accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum);Executed by:
| 14 | ||||||||||||
| 122 | else | - | ||||||||||||
| 123 | accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(value); executed 252 times by 1 test: accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(value);Executed by:
| 252 | ||||||||||||
| 124 | - | |||||||||||||
| 125 | - | |||||||||||||
| 126 | if (accepted
| 12-408 | ||||||||||||
| 127 | resultAccepted = true; executed 408 times by 2 tests: resultAccepted = true;Executed by:
| 408 | ||||||||||||
| 128 | else | - | ||||||||||||
| 129 | iterationCount *= 2; executed 12 times by 1 test: iterationCount *= 2;Executed by:
| 12 | ||||||||||||
| 130 | - | |||||||||||||
| 131 | this->result = QBenchmarkResult( | - | ||||||||||||
| 132 | QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro); | - | ||||||||||||
| 133 | } executed 420 times by 2 tests: end of blockExecuted by:
| 420 | ||||||||||||
| 134 | QTest::QBenchmarkIterationController::QBenchmarkIterationController(RunMode runMode) | - | ||||||||||||
| 135 | { | - | ||||||||||||
| 136 | i = 0; | - | ||||||||||||
| 137 | if (runMode == RunOnce
| 0-16 | ||||||||||||
| 138 | QBenchmarkTestMethodData::current->runOnce = true; executed 16 times by 1 test: QBenchmarkTestMethodData::current->runOnce = true;Executed by:
| 16 | ||||||||||||
| 139 | QTest::beginBenchmarkMeasurement(); | - | ||||||||||||
| 140 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | QTest::QBenchmarkIterationController::QBenchmarkIterationController() | - | ||||||||||||
| 143 | { | - | ||||||||||||
| 144 | i = 0; | - | ||||||||||||
| 145 | QTest::beginBenchmarkMeasurement(); | - | ||||||||||||
| 146 | } executed 404 times by 1 test: end of blockExecuted by:
| 404 | ||||||||||||
| 147 | - | |||||||||||||
| 148 | - | |||||||||||||
| 149 | - | |||||||||||||
| 150 | QTest::QBenchmarkIterationController::~QBenchmarkIterationController() | - | ||||||||||||
| 151 | { | - | ||||||||||||
| 152 | const qreal result = QTest::endBenchmarkMeasurement(); | - | ||||||||||||
| 153 | QBenchmarkTestMethodData::current->setResult(result, QBenchmarkGlobalData::current->measurer->metricType()); | - | ||||||||||||
| 154 | } executed 420 times by 2 tests: end of blockExecuted by:
| 420 | ||||||||||||
| 155 | - | |||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | bool QTest::QBenchmarkIterationController::isDone() | - | ||||||||||||
| 159 | { | - | ||||||||||||
| 160 | if (QBenchmarkTestMethodData::current->runOnce
| 32-1026 | ||||||||||||
| 161 | return executed 32 times by 1 test: i > 0;return i > 0;Executed by:
executed 32 times by 1 test: return i > 0;Executed by:
| 32 | ||||||||||||
| 162 | return executed 1026 times by 1 test: i >= QTest::iterationCount();return i >= QTest::iterationCount();Executed by:
executed 1026 times by 1 test: return i >= QTest::iterationCount();Executed by:
| 1026 | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | - | |||||||||||||
| 166 | - | |||||||||||||
| 167 | void QTest::QBenchmarkIterationController::next() | - | ||||||||||||
| 168 | { | - | ||||||||||||
| 169 | ++i; | - | ||||||||||||
| 170 | } executed 638 times by 2 tests: end of blockExecuted by:
| 638 | ||||||||||||
| 171 | - | |||||||||||||
| 172 | - | |||||||||||||
| 173 | - | |||||||||||||
| 174 | int QTest::iterationCount() | - | ||||||||||||
| 175 | { | - | ||||||||||||
| 176 | return executed 1026 times by 1 test: QBenchmarkTestMethodData::current->iterationCount;return QBenchmarkTestMethodData::current->iterationCount;Executed by:
executed 1026 times by 1 test: return QBenchmarkTestMethodData::current->iterationCount;Executed by:
| 1026 | ||||||||||||
| 177 | } | - | ||||||||||||
| 178 | - | |||||||||||||
| 179 | - | |||||||||||||
| 180 | - | |||||||||||||
| 181 | void QTest::setIterationCountHint(int count) | - | ||||||||||||
| 182 | { | - | ||||||||||||
| 183 | QBenchmarkTestMethodData::current->adjustIterationCount(count); | - | ||||||||||||
| 184 | } never executed: end of block | 0 | ||||||||||||
| 185 | - | |||||||||||||
| 186 | - | |||||||||||||
| 187 | - | |||||||||||||
| 188 | void QTest::setIterationCount(int count) | - | ||||||||||||
| 189 | { | - | ||||||||||||
| 190 | QBenchmarkTestMethodData::current->iterationCount = count; | - | ||||||||||||
| 191 | QBenchmarkTestMethodData::current->resultAccepted = true; | - | ||||||||||||
| 192 | } never executed: end of block | 0 | ||||||||||||
| 193 | - | |||||||||||||
| 194 | - | |||||||||||||
| 195 | - | |||||||||||||
| 196 | void QTest::beginBenchmarkMeasurement() | - | ||||||||||||
| 197 | { | - | ||||||||||||
| 198 | QBenchmarkGlobalData::current->measurer->start(); | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | } executed 420 times by 2 tests: end of blockExecuted by:
| 420 | ||||||||||||
| 201 | - | |||||||||||||
| 202 | - | |||||||||||||
| 203 | - | |||||||||||||
| 204 | quint64 QTest::endBenchmarkMeasurement() | - | ||||||||||||
| 205 | { | - | ||||||||||||
| 206 | - | |||||||||||||
| 207 | return executed 420 times by 2 tests: QBenchmarkGlobalData::current->measurer->stop();return QBenchmarkGlobalData::current->measurer->stop();Executed by:
executed 420 times by 2 tests: return QBenchmarkGlobalData::current->measurer->stop();Executed by:
| 420 | ||||||||||||
| 208 | } | - | ||||||||||||
| 209 | void QTest::setBenchmarkResult(qreal result, QTest::QBenchmarkMetric metric) | - | ||||||||||||
| 210 | { | - | ||||||||||||
| 211 | QBenchmarkTestMethodData::current->setResult(result, metric, false); | - | ||||||||||||
| 212 | } never executed: end of block | 0 | ||||||||||||
| 213 | - | |||||||||||||
| 214 | template <typename T> | - | ||||||||||||
| 215 | typename T::value_type qAverage(const T &container) | - | ||||||||||||
| 216 | { | - | ||||||||||||
| 217 | typename T::const_iterator it = container.constBegin(); | - | ||||||||||||
| 218 | typename T::const_iterator end = container.constEnd(); | - | ||||||||||||
| 219 | typename T::value_type acc = typename T::value_type(); | - | ||||||||||||
| 220 | int count = 0; | - | ||||||||||||
| 221 | while (it != end
| 0 | ||||||||||||
| 222 | acc += *it; | - | ||||||||||||
| 223 | ++it; | - | ||||||||||||
| 224 | ++count; | - | ||||||||||||
| 225 | } never executed: end of block | 0 | ||||||||||||
| 226 | return never executed: acc / count;return acc / count;never executed: return acc / count; | 0 | ||||||||||||
| 227 | } | - | ||||||||||||
| 228 | - | |||||||||||||
| 229 | - | |||||||||||||
| Switch to Source code | Preprocessed file |