Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
11
12// QBenchmarkTimeMeasurer implementation
13
14void QBenchmarkTimeMeasurer::start()
15{
16 time.start();
17}
18
19void 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
26QList<QBenchmarkMeasurerBase::Measurement> QBenchmarkTimeMeasurer::stop()
27{
28 return { { accumulator.total(),
29 accumulator.variance() / QBenchmarkTestMethodData::current->measurementBlockSize,
30 QTest::WalltimeMilliseconds } };
31}
32
33bool QBenchmarkTimeMeasurer::isMeasurementAccepted(Measurement measurement)
34{
35 return (measurement.value > 50);
36}
37
38int QBenchmarkTimeMeasurer::adjustIterationCount(int suggestion)
39{
40 return suggestion;
41}
42
43bool QBenchmarkTimeMeasurer::needsWarmupIteration()
44{
45 return true;
46}
47
48int QBenchmarkTimeMeasurer::adjustMedianCount(int)
49{
50 return 1;
51}
52
53#ifdef HAVE_TICK_COUNTER // defined in 3rdparty/cycle/cycle_p.h
54
55void QBenchmarkTickMeasurer::start()
56{
57 startTicks = getticks();
58}
59
60void QBenchmarkTickMeasurer::updateMeasurement()
61{
62 const qreal value = qreal(elapsed(getticks(), startTicks));
63 accumulator.update(value);
64 startTicks = getticks();
65}
66
67QList<QBenchmarkMeasurerBase::Measurement> QBenchmarkTickMeasurer::stop()
68{
69 return { { accumulator.total(),
70 accumulator.variance() / QBenchmarkTestMethodData::current->measurementBlockSize,
71 QTest::CPUTicks } };
72}
73
74bool QBenchmarkTickMeasurer::isMeasurementAccepted(QBenchmarkMeasurerBase::Measurement)
75{
76 return true;
77}
78
79int QBenchmarkTickMeasurer::adjustIterationCount(int)
80{
81 return 1;
82}
83
84int QBenchmarkTickMeasurer::adjustMedianCount(int)
85{
86 return 1;
87}
88
89bool QBenchmarkTickMeasurer::needsWarmupIteration()
90{
91 return true;
92}
93
94#endif
95
96
97QT_END_NAMESPACE
Combined button and popup list for selecting options.