qbenchmark.cpp

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

Generated by Squish Coco Non-Commercial