qbenchmark.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/testlib/qbenchmark.cpp
Switch to Source codePreprocessed file
LineSourceCount
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 , minimumTotal(-1)-
15 , mode_(WallTime)-
16{-
17 setMode(mode_);-
18}
executed 815 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
815
19-
20QBenchmarkGlobalData::~QBenchmarkGlobalData()-
21{-
22 delete measurer;-
23 QBenchmarkGlobalData::current = 0;-
24}
executed 1238 times by 508 tests: end of block
Executed by:
  • tst_collections - unknown status
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractanimation - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qabstractitemmodel - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qabstractprintdialog - unknown status
  • tst_qabstractproxymodel - unknown status
  • tst_qabstractscrollarea - unknown status
  • tst_qabstractslider - unknown status
  • tst_qabstractsocket - unknown status
  • tst_qabstractspinbox - unknown status
  • tst_qabstracttextdocumentlayout - unknown status
  • tst_qaccessibility - unknown status
  • tst_qaction - unknown status
  • ...
1238
25-
26void QBenchmarkGlobalData::setMode(Mode mode)-
27{-
28 mode_ = mode;-
29-
30 if (measurer
measurerDescription
TRUEevaluated 73 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 815 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
73-815
31 delete measurer;
executed 73 times by 1 test: delete measurer;
Executed by:
  • tst_selftests - unknown status
73
32 measurer = createMeasurer();-
33}
executed 888 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
888
34-
35QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer()-
36{-
37 QBenchmarkMeasurerBase *measurer = 0;-
38 if (0) {
dead code: { }
-
39-
40 }
dead code: { }
else if (mode_ == CallgrindChildProcess
mode_ == CallgrindChildProcessDescription
TRUEnever evaluated
FALSEevaluated 888 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| mode_ == CallgrindParentProcess
mode_ == Callg...dParentProcessDescription
TRUEnever evaluated
FALSEevaluated 888 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
-
41 measurer = new QBenchmarkCallgrindMeasurer;-
42-
43-
44 }
never executed: end of block
else if (mode_ == PerfCounter
mode_ == PerfCounterDescription
TRUEnever evaluated
FALSEevaluated 888 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
0-888
45 measurer = new QBenchmarkPerfEventsMeasurer;-
46-
47-
48 }
never executed: end of block
else if (mode_ == TickCounter
mode_ == TickCounterDescription
TRUEnever evaluated
FALSEevaluated 888 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
0-888
49 measurer = new QBenchmarkTickMeasurer;-
50-
51 }
never executed: end of block
else if (mode_ == EventCounter
mode_ == EventCounterDescription
TRUEevaluated 73 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 815 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
0-815
52 measurer = new QBenchmarkEvent;-
53 }
executed 73 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
else {
73
54 measurer = new QBenchmarkTimeMeasurer;-
55 }
executed 815 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
815
56 measurer->init();-
57 return
executed 888 times by 1 test: return measurer;
Executed by:
  • tst_selftests - unknown status
measurer;
executed 888 times by 1 test: return measurer;
Executed by:
  • tst_selftests - unknown status
888
58}-
59-
60int QBenchmarkGlobalData::adjustMedianIterationCount()-
61{-
62 if (medianIterationCount != -1
medianIterationCount != -1Description
TRUEnever evaluated
FALSEevaluated 408 times by 2 tests
Evaluated by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
) {
0-408
63 return
never executed: return medianIterationCount;
medianIterationCount;
never executed: return medianIterationCount;
0
64 } else {-
65 return
executed 408 times by 2 tests: return measurer->adjustMedianCount(1);
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
measurer->adjustMedianCount(1);
executed 408 times by 2 tests: return measurer->adjustMedianCount(1);
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
408
66 }-
67}-
68-
69-
70QBenchmarkTestMethodData *QBenchmarkTestMethodData::current;-
71-
72QBenchmarkTestMethodData::QBenchmarkTestMethodData()-
73:resultAccepted(false), runOnce(false), iterationCount(-1)-
74{-
75}
executed 13256 times by 502 tests: end of block
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
13256
76-
77QBenchmarkTestMethodData::~QBenchmarkTestMethodData()-
78{-
79 QBenchmarkTestMethodData::current = 0;-
80}
executed 13199 times by 502 tests: end of block
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
13199
81-
82void QBenchmarkTestMethodData::beginDataRun()-
83{-
84 iterationCount = adjustIterationCount(1);-
85}
executed 126618 times by 502 tests: end of block
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
126618
86-
87void QBenchmarkTestMethodData::endDataRun()-
88{-
89}-
90-
91int QBenchmarkTestMethodData::adjustIterationCount(int suggestion)-
92{-
93-
94 if (QBenchmarkGlobalData::current->iterationCount != -1
QBenchmarkGlob...ionCount != -1Description
TRUEevaluated 240 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 126378 times by 502 tests
Evaluated by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
) {
240-126378
95 iterationCount = QBenchmarkGlobalData::current->iterationCount;-
96 }
executed 240 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
else {
240
97 iterationCount = QBenchmarkGlobalData::current->measurer->adjustIterationCount(suggestion);-
98 }
executed 126378 times by 502 tests: end of block
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
126378
99-
100 return
executed 126618 times by 502 tests: return iterationCount;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
iterationCount;
executed 126618 times by 502 tests: return iterationCount;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
126618
101}-
102-
103void QBenchmarkTestMethodData::setResult(-
104 qreal value, QTest::QBenchmarkMetric metric, bool setByMacro)-
105{-
106 bool accepted = false;-
107-
108-
109-
110 if (QBenchmarkGlobalData::current->iterationCount != -1
QBenchmarkGlob...ionCount != -1Description
TRUEevaluated 138 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 282 times by 2 tests
Evaluated by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
)
138-282
111 accepted = true;
executed 138 times by 1 test: accepted = true;
Executed by:
  • tst_selftests - unknown status
138
112-
113 else if (QBenchmarkTestMethodData::current->runOnce
QBenchmarkTest...rrent->runOnceDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QByteDataBuffer
FALSEevaluated 266 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| !setByMacro
!setByMacroDescription
TRUEnever evaluated
FALSEevaluated 266 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
0-266
114 iterationCount = 1;-
115 accepted = true;-
116 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_QByteDataBuffer
16
117-
118-
119-
120 else if (QBenchmarkGlobalData::current->walltimeMinimum != -1
QBenchmarkGlob...eMinimum != -1Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 252 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
14-252
121 accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum);
executed 14 times by 1 test: accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum);
Executed by:
  • tst_selftests - unknown status
14
122 else-
123 accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(value);
executed 252 times by 1 test: accepted = QBenchmarkGlobalData::current->measurer->isMeasurementAccepted(value);
Executed by:
  • tst_selftests - unknown status
252
124-
125-
126 if (accepted
acceptedDescription
TRUEevaluated 408 times by 2 tests
Evaluated by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
12-408
127 resultAccepted = true;
executed 408 times by 2 tests: resultAccepted = true;
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
408
128 else-
129 iterationCount *= 2;
executed 12 times by 1 test: iterationCount *= 2;
Executed by:
  • tst_selftests - unknown status
12
130-
131 this->result = QBenchmarkResult(-
132 QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro);-
133}
executed 420 times by 2 tests: end of block
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
420
134QTest::QBenchmarkIterationController::QBenchmarkIterationController(RunMode runMode)-
135{-
136 i = 0;-
137 if (runMode == RunOnce
runMode == RunOnceDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QByteDataBuffer
FALSEnever evaluated
)
0-16
138 QBenchmarkTestMethodData::current->runOnce = true;
executed 16 times by 1 test: QBenchmarkTestMethodData::current->runOnce = true;
Executed by:
  • tst_QByteDataBuffer
16
139 QTest::beginBenchmarkMeasurement();-
140}
executed 16 times by 1 test: end of block
Executed by:
  • tst_QByteDataBuffer
16
141-
142QTest::QBenchmarkIterationController::QBenchmarkIterationController()-
143{-
144 i = 0;-
145 QTest::beginBenchmarkMeasurement();-
146}
executed 404 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
404
147-
148-
149-
150QTest::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 block
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
420
155-
156-
157-
158bool QTest::QBenchmarkIterationController::isDone()-
159{-
160 if (QBenchmarkTestMethodData::current->runOnce
QBenchmarkTest...rrent->runOnceDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_QByteDataBuffer
FALSEevaluated 1026 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
32-1026
161 return
executed 32 times by 1 test: return i > 0;
Executed by:
  • tst_QByteDataBuffer
i > 0;
executed 32 times by 1 test: return i > 0;
Executed by:
  • tst_QByteDataBuffer
32
162 return
executed 1026 times by 1 test: return i >= QTest::iterationCount();
Executed by:
  • tst_selftests - unknown status
i >= QTest::iterationCount();
executed 1026 times by 1 test: return i >= QTest::iterationCount();
Executed by:
  • tst_selftests - unknown status
1026
163}-
164-
165-
166-
167void QTest::QBenchmarkIterationController::next()-
168{-
169 ++i;-
170}
executed 638 times by 2 tests: end of block
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
638
171-
172-
173-
174int QTest::iterationCount()-
175{-
176 return
executed 1026 times by 1 test: return QBenchmarkTestMethodData::current->iterationCount;
Executed by:
  • tst_selftests - unknown status
QBenchmarkTestMethodData::current->iterationCount;
executed 1026 times by 1 test: return QBenchmarkTestMethodData::current->iterationCount;
Executed by:
  • tst_selftests - unknown status
1026
177}-
178-
179-
180-
181void QTest::setIterationCountHint(int count)-
182{-
183 QBenchmarkTestMethodData::current->adjustIterationCount(count);-
184}
never executed: end of block
0
185-
186-
187-
188void 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-
196void QTest::beginBenchmarkMeasurement()-
197{-
198 QBenchmarkGlobalData::current->measurer->start();-
199-
200}
executed 420 times by 2 tests: end of block
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
420
201-
202-
203-
204quint64 QTest::endBenchmarkMeasurement()-
205{-
206-
207 return
executed 420 times by 2 tests: return QBenchmarkGlobalData::current->measurer->stop();
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
QBenchmarkGlobalData::current->measurer->stop();
executed 420 times by 2 tests: return QBenchmarkGlobalData::current->measurer->stop();
Executed by:
  • tst_QByteDataBuffer
  • tst_selftests - unknown status
420
208}-
209void QTest::setBenchmarkResult(qreal result, QTest::QBenchmarkMetric metric)-
210{-
211 QBenchmarkTestMethodData::current->setResult(result, metric, false);-
212}
never executed: end of block
0
213-
214template <typename T>-
215typename 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
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
222 acc += *it;-
223 ++it;-
224 ++count;-
225 }
never executed: end of block
0
226 return
never executed: return acc / count;
acc / count;
never executed: return acc / count;
0
227}-
228-
229-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9