Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qbenchmarkmeasurement.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
<
QtTest
/
private
/
qbenchmarktimemeasurers_p
.
h
>
5
#
include
<
QtTest
/
private
/
qbenchmark_p
.
h
>
6
#
include
<
QtTest
/
private
/
qbenchmarkmetric_p
.
h
>
7
#
include
<
QtTest
/
qbenchmark
.
h
>
8
#
include
<
qdebug
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
// QBenchmarkTimeMeasurer implementation
13
14
void
QBenchmarkTimeMeasurer::start()
15
{
16
time.start();
17
}
18
19
void
QBenchmarkTimeMeasurer::updateMeasurement()
20
{
21
const
qreal value = std::chrono::duration<qreal, std::milli>(time.durationElapsed()).count();
22
accumulator.update(value);
23
time.restart();
24
}
25
26
QList<QBenchmarkMeasurerBase::Measurement> QBenchmarkTimeMeasurer::stop()
27
{
28
return
{ { accumulator.total(),
29
accumulator.variance() / QBenchmarkTestMethodData::current->measurementBlockSize,
30
QTest::WalltimeMilliseconds } };
31
}
32
33
bool
QBenchmarkTimeMeasurer::isMeasurementAccepted(Measurement measurement)
34
{
35
return
(measurement.value > 50);
36
}
37
38
int
QBenchmarkTimeMeasurer::adjustIterationCount(
int
suggestion)
39
{
40
return
suggestion;
41
}
42
43
bool
QBenchmarkTimeMeasurer::needsWarmupIteration()
44
{
45
return
true
;
46
}
47
48
int
QBenchmarkTimeMeasurer::adjustMedianCount(
int
)
49
{
50
return
1;
51
}
52
53
#
ifdef
HAVE_TICK_COUNTER
// defined in 3rdparty/cycle/cycle_p.h
54
55
void
QBenchmarkTickMeasurer::start()
56
{
57
startTicks = getticks();
58
}
59
60
void
QBenchmarkTickMeasurer::updateMeasurement()
61
{
62
const
qreal value = qreal(elapsed(getticks(), startTicks));
63
accumulator.update(value);
64
startTicks = getticks();
65
}
66
67
QList<QBenchmarkMeasurerBase::Measurement> QBenchmarkTickMeasurer::stop()
68
{
69
return
{ { accumulator.total(),
70
accumulator.variance() / QBenchmarkTestMethodData::current->measurementBlockSize,
71
QTest::CPUTicks } };
72
}
73
74
bool
QBenchmarkTickMeasurer::isMeasurementAccepted(QBenchmarkMeasurerBase::Measurement)
75
{
76
return
true
;
77
}
78
79
int
QBenchmarkTickMeasurer::adjustIterationCount(
int
)
80
{
81
return
1;
82
}
83
84
int
QBenchmarkTickMeasurer::adjustMedianCount(
int
)
85
{
86
return
1;
87
}
88
89
bool
QBenchmarkTickMeasurer::needsWarmupIteration()
90
{
91
return
true
;
92
}
93
94
#
endif
95
96
97
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
testlib
qbenchmarkmeasurement.cpp
Generated on
for Qt by
1.18.0