Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qbenchmarkevent.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/qbenchmarkevent_p.h>
5#include <QtTest/private/qbenchmark_p.h>
6#include <QtTest/private/qbenchmarkmetric_p.h>
7#include <qdebug.h>
8
10
12
14
16{
17 eventCounter = 0;
18 QAbstractEventDispatcher::instance()->installNativeEventFilter(this);
19}
20
21QList<QBenchmarkMeasurerBase::Measurement> QBenchmarkEvent::stop()
22{
23 QAbstractEventDispatcher::instance()->removeNativeEventFilter(this);
24 return { { qreal(eventCounter), QTest::Events } };
25}
26
27// It's very tempting to simply reject a measurement if 0 events
28// where counted, however that is a possible situation and returning
29// false here will create a infinite loop. Do not change this.
31{
32 Q_UNUSED(measurement);
33 return true;
34}
35
37{
38 return suggestion;
39}
40
42{
43 Q_UNUSED(suggestion);
44 return 1;
45}
46
47// This could be done in a much better way, this is just the beginning.
48#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
50#else
51bool QBenchmarkEvent::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
52#endif
53{
54 Q_UNUSED(eventType);
57
58 eventCounter++;
59 return false;
60}
61
static QAbstractEventDispatcher * instance(QThread *thread=nullptr)
Returns a pointer to the event dispatcher object for the specified thread.
void start() override
QList< Measurement > stop() override
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override
This method is called for every native event.
int adjustIterationCount(int suggestion) override
int adjustMedianCount(int suggestion) override
bool isMeasurementAccepted(Measurement measurement) override
\inmodule QtCore
Definition qbytearray.h:57
Combined button and popup list for selecting options.
GLuint GLsizei const GLchar * message
GLuint64EXT * result
[6]
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
ptrdiff_t qintptr
Definition qtypes.h:166