summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/corelib/kernel')
-rw-r--r--tests/benchmarks/corelib/kernel/CMakeLists.txt4
-rw-r--r--tests/benchmarks/corelib/kernel/events/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp (renamed from tests/benchmarks/corelib/kernel/events/main.cpp)32
-rw-r--r--tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/kernel/qcoreapplication/main.cpp69
-rw-r--r--tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp70
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp55
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp (renamed from tests/benchmarks/corelib/kernel/qmetaobject/main.cpp)75
-rw-r--r--tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp (renamed from tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp)118
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/object.cpp29
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/object.h29
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp (renamed from tests/benchmarks/corelib/kernel/qobject/main.cpp)57
-rw-r--r--tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt7
-rw-r--r--tests/benchmarks/corelib/kernel/qproperty/propertytester.h29
-rw-r--r--tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp (renamed from tests/benchmarks/corelib/kernel/qproperty/main.cpp)60
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt8
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp33
-rw-r--r--tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt14
-rw-r--r--tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp (renamed from tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp)103
-rw-r--r--tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp (renamed from tests/benchmarks/corelib/kernel/qwineventnotifier/main.cpp)39
25 files changed, 335 insertions, 566 deletions
diff --git a/tests/benchmarks/corelib/kernel/CMakeLists.txt b/tests/benchmarks/corelib/kernel/CMakeLists.txt
index 34d457bb21..137ef37298 100644
--- a/tests/benchmarks/corelib/kernel/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from kernel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(events)
add_subdirectory(qmetatype)
@@ -6,6 +7,7 @@ add_subdirectory(qvariant)
add_subdirectory(qcoreapplication)
add_subdirectory(qtimer_vs_qmetaobject)
add_subdirectory(qproperty)
+add_subdirectory(qmetaenum)
if(TARGET Qt::Widgets)
add_subdirectory(qmetaobject)
add_subdirectory(qobject)
diff --git a/tests/benchmarks/corelib/kernel/events/CMakeLists.txt b/tests/benchmarks/corelib/kernel/events/CMakeLists.txt
index 41add9350e..ba175fd3a0 100644
--- a/tests/benchmarks/corelib/kernel/events/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/events/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from events.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_events Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_events
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_events.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:events.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/kernel/events/main.cpp b/tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp
index 973d96261c..17eb838af2 100644
--- a/tests/benchmarks/corelib/kernel/events/main.cpp
+++ b/tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <qtest.h>
@@ -113,6 +88,7 @@ void EventsBench::noEvent()
QBENCHMARK {
val += tst.foo(1);
}
+ QVERIFY(val > 0);
}
void EventsBench::sendEvent_data()
@@ -171,4 +147,4 @@ void EventsBench::postEvent()
QTEST_MAIN(EventsBench)
-#include "main.moc"
+#include "tst_bench_events.moc"
diff --git a/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt
index 1618997909..1a553199d3 100644
--- a/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qcoreapplication.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qcoreapplication Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_qcoreapplication
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qcoreapplication.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qcoreapplication.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/kernel/qcoreapplication/main.cpp b/tests/benchmarks/corelib/kernel/qcoreapplication/main.cpp
deleted file mode 100644
index 018f689785..0000000000
--- a/tests/benchmarks/corelib/kernel/qcoreapplication/main.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Robin Burchell <robin+qt@viroteck.net>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtCore>
-#include <qtest.h>
-#include <qcoreapplication.h>
-
-class QCoreApplicationBenchmark : public QObject
-{
-Q_OBJECT
-private slots:
- void event_posting_benchmark_data();
- void event_posting_benchmark();
-};
-
-void QCoreApplicationBenchmark::event_posting_benchmark_data()
-{
- QTest::addColumn<int>("size");
- QTest::newRow("50 events") << 50;
- QTest::newRow("100 events") << 100;
- QTest::newRow("200 events") << 200;
- QTest::newRow("1000 events") << 1000;
- QTest::newRow("10000 events") << 10000;
- QTest::newRow("100000 events") << 100000;
- QTest::newRow("1000000 events") << 1000000;
-}
-
-void QCoreApplicationBenchmark::event_posting_benchmark()
-{
- QFETCH(int, size);
-
- int type = QEvent::registerEventType();
- QCoreApplication *app = QCoreApplication::instance();
-
- // benchmark posting & sending events
- QBENCHMARK {
- for (int i = 0; i < size; ++i)
- QCoreApplication::postEvent(app, new QEvent(QEvent::Type(type)));
- QCoreApplication::sendPostedEvents();
- }
-}
-
-QTEST_MAIN(QCoreApplicationBenchmark)
-
-#include "main.moc"
diff --git a/tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp b/tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp
new file mode 100644
index 0000000000..d2ff489784
--- /dev/null
+++ b/tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp
@@ -0,0 +1,70 @@
+// Copyright (C) 2011 Robin Burchell <robin+qt@viroteck.net>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#include <QtCore>
+#include <qtest.h>
+#include <qcoreapplication.h>
+
+class tst_QCoreApplication : public QObject
+{
+Q_OBJECT
+private slots:
+ void event_posting_benchmark_data();
+ void event_posting_benchmark();
+
+ void event_posting_multiple_objects_benchmark_data();
+ void event_posting_multiple_objects_benchmark();
+};
+
+void tst_QCoreApplication::event_posting_benchmark_data()
+{
+ QTest::addColumn<int>("size");
+ QTest::newRow("50 events") << 50;
+ QTest::newRow("100 events") << 100;
+ QTest::newRow("200 events") << 200;
+ QTest::newRow("1000 events") << 1000;
+ QTest::newRow("10000 events") << 10000;
+ QTest::newRow("100000 events") << 100000;
+ QTest::newRow("1000000 events") << 1000000;
+}
+
+void tst_QCoreApplication::event_posting_benchmark()
+{
+ QFETCH(int, size);
+
+ int type = QEvent::registerEventType();
+ QCoreApplication *app = QCoreApplication::instance();
+
+ // benchmark posting & sending events
+ QBENCHMARK {
+ for (int i = 0; i < size; ++i)
+ QCoreApplication::postEvent(app, new QEvent(QEvent::Type(type)));
+ QCoreApplication::sendPostedEvents();
+ }
+}
+
+void tst_QCoreApplication::event_posting_multiple_objects_benchmark_data()
+{
+ event_posting_benchmark_data();
+}
+
+void tst_QCoreApplication::event_posting_multiple_objects_benchmark()
+{
+ QFETCH(int, size);
+
+ QObject objects[15]; // The size of the array has not been chosen through any meaningful means
+
+ QRandomGenerator gen;
+
+ // benchmark posting & sending events
+ QBENCHMARK {
+ for (int i = 0; i < size; ++i) {
+ QCoreApplication::postEvent(&objects[gen.bounded(0, int(std::size(objects)))],
+ new QTimerEvent(i % 10));
+ }
+ QCoreApplication::sendPostedEvents();
+ }
+}
+
+QTEST_MAIN(tst_QCoreApplication)
+
+#include "tst_bench_qcoreapplication.moc"
diff --git a/tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt
new file mode 100644
index 0000000000..78bc30ea73
--- /dev/null
+++ b/tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_benchmark(tst_bench_qmetaenum
+ SOURCES
+ tst_bench_qmetaenum.cpp
+ LIBRARIES
+ Qt::Core
+ Qt::Test
+)
diff --git a/tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp b/tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp
new file mode 100644
index 0000000000..1a88c49993
--- /dev/null
+++ b/tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp
@@ -0,0 +1,55 @@
+// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QMetaEnum>
+#include <QTest>
+
+class tst_QMetaEnum: public QObject
+{
+ Q_OBJECT
+public:
+ using QObject::QObject;
+
+private Q_SLOTS:
+ void valueToKeys_data();
+ void valueToKeys();
+ void keysToValue_data() { valueToKeys_data(); }
+ void keysToValue();
+};
+
+void tst_QMetaEnum::valueToKeys_data()
+{
+ QTest::addColumn<int>("buttons");
+ QTest::addColumn<QByteArray>("string");
+ // Qt::MouseButtons has at least 24 enumerators, so it's a good performance test
+ const auto me = QMetaEnum::fromType<Qt::MouseButtons>();
+ int accu = 0;
+ for (int i = 0; i < std::min(31, me.keyCount()); ++i) {
+ accu <<= 1;
+ accu |= 1;
+ QTest::addRow("%d bits set", i) << accu << me.valueToKeys(accu);
+ }
+}
+
+void tst_QMetaEnum::valueToKeys()
+{
+ QFETCH(const int, buttons);
+ const auto me = QMetaEnum::fromType<Qt::MouseButtons>();
+ QBENCHMARK {
+ [[maybe_unused]] auto r = me.valueToKeys(buttons);
+ }
+}
+
+void tst_QMetaEnum::keysToValue()
+{
+ QFETCH(const QByteArray, string);
+ const auto me = QMetaEnum::fromType<Qt::MouseButtons>();
+ bool ok;
+ QBENCHMARK {
+ [[maybe_unused]] auto r = me.keysToValue(string.data(), &ok);
+ }
+}
+
+QTEST_MAIN(tst_QMetaEnum)
+
+#include "tst_bench_qmetaenum.moc"
diff --git a/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt
index db4c3ab12e..9e17608c57 100644
--- a/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qmetaobject.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qmetaobject Binary:
@@ -6,12 +7,9 @@
qt_internal_add_benchmark(tst_bench_qmetaobject
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qmetaobject.cpp
+ LIBRARIES
Qt::Gui
Qt::Test
Qt::Widgets
)
-
-#### Keys ignored in scope 1:.:.:qmetaobject.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/kernel/qmetaobject/main.cpp b/tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp
index 80bad7977b..6b02fb4ba4 100644
--- a/tests/benchmarks/corelib/kernel/qmetaobject/main.cpp
+++ b/tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp
@@ -1,35 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <QtWidgets/QTreeView>
#include <qtest.h>
-class LotsOfSignals : public QObject
+class LotsOfSignals : public QObject // for the unconnected() test
{
Q_OBJECT
public:
@@ -107,13 +82,10 @@ signals:
void extraSignal70();
};
-class tst_qmetaobject: public QObject
+class tst_QMetaObject: public QObject
{
Q_OBJECT
private slots:
- void initTestCase();
- void cleanupTestCase();
-
void indexOfProperty_data();
void indexOfProperty();
void indexOfMethod_data();
@@ -127,15 +99,7 @@ private slots:
void unconnected();
};
-void tst_qmetaobject::initTestCase()
-{
-}
-
-void tst_qmetaobject::cleanupTestCase()
-{
-}
-
-void tst_qmetaobject::indexOfProperty_data()
+void tst_QMetaObject::indexOfProperty_data()
{
QTest::addColumn<QByteArray>("name");
const QMetaObject *mo = &QTreeView::staticMetaObject;
@@ -145,7 +109,7 @@ void tst_qmetaobject::indexOfProperty_data()
}
}
-void tst_qmetaobject::indexOfProperty()
+void tst_QMetaObject::indexOfProperty()
{
QFETCH(QByteArray, name);
const char *p = name.constData();
@@ -155,7 +119,7 @@ void tst_qmetaobject::indexOfProperty()
}
}
-void tst_qmetaobject::indexOfMethod_data()
+void tst_QMetaObject::indexOfMethod_data()
{
QTest::addColumn<QByteArray>("method");
const QMetaObject *mo = &QTreeView::staticMetaObject;
@@ -166,7 +130,7 @@ void tst_qmetaobject::indexOfMethod_data()
}
}
-void tst_qmetaobject::indexOfMethod()
+void tst_QMetaObject::indexOfMethod()
{
QFETCH(QByteArray, method);
const char *p = method.constData();
@@ -176,7 +140,7 @@ void tst_qmetaobject::indexOfMethod()
}
}
-void tst_qmetaobject::indexOfSignal_data()
+void tst_QMetaObject::indexOfSignal_data()
{
QTest::addColumn<QByteArray>("signal");
const QMetaObject *mo = &QTreeView::staticMetaObject;
@@ -189,7 +153,7 @@ void tst_qmetaobject::indexOfSignal_data()
}
}
-void tst_qmetaobject::indexOfSignal()
+void tst_QMetaObject::indexOfSignal()
{
QFETCH(QByteArray, signal);
const char *p = signal.constData();
@@ -199,7 +163,7 @@ void tst_qmetaobject::indexOfSignal()
}
}
-void tst_qmetaobject::indexOfSlot_data()
+void tst_QMetaObject::indexOfSlot_data()
{
QTest::addColumn<QByteArray>("slot");
const QMetaObject *mo = &QTreeView::staticMetaObject;
@@ -212,7 +176,7 @@ void tst_qmetaobject::indexOfSlot_data()
}
}
-void tst_qmetaobject::indexOfSlot()
+void tst_QMetaObject::indexOfSlot()
{
QFETCH(QByteArray, slot);
const char *p = slot.constData();
@@ -222,7 +186,7 @@ void tst_qmetaobject::indexOfSlot()
}
}
-void tst_qmetaobject::unconnected_data()
+void tst_QMetaObject::unconnected_data()
{
QTest::addColumn<int>("signal_index");
QTest::newRow("signal--9") << 9;
@@ -233,19 +197,20 @@ void tst_qmetaobject::unconnected_data()
QTest::newRow("signal--70") << 70;
}
-void tst_qmetaobject::unconnected()
+void tst_QMetaObject::unconnected()
{
LotsOfSignals *obj = new LotsOfSignals;
QFETCH(int, signal_index);
- QVERIFY(obj->metaObject()->methodCount() == 73);
+ // 74: 70 signals in LotsOfSignals, 2 signals, 1 slot + 1 invokable in QObject
+ QCOMPARE(obj->metaObject()->methodCount(), 74);
void *v;
QBENCHMARK {
- //+1 because QObject has one slot
- QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, signal_index+1, &v);
+ // Add two because QObject has one slot and one invokable
+ QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, signal_index + 2, &v);
}
delete obj;
}
-QTEST_MAIN(tst_qmetaobject)
+QTEST_MAIN(tst_QMetaObject)
-#include "main.moc"
+#include "tst_bench_qmetaobject.moc"
diff --git a/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt
index ae4bc9c906..f24a29d144 100644
--- a/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qmetatype.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qmetatype Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_qmetatype
SOURCES
- tst_qmetatype.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qmetatype.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qmetatype.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp
index 126af8adde..94adfa4a8c 100644
--- a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtest.h>
#include <QtCore/qmetatype.h>
@@ -85,9 +60,8 @@ void tst_QMetaType::typeBuiltin_data()
{
QTest::addColumn<QByteArray>("typeName");
for (int i = 0; i < QMetaType::User; ++i) {
- const char *name = QMetaType::typeName(i);
- if (name)
- QTest::newRow(name) << QByteArray(name);
+ if (QMetaType metaType(i); metaType.isValid())
+ QTest::newRow(metaType.name()) << QByteArray(metaType.name());
}
}
@@ -98,7 +72,7 @@ void tst_QMetaType::typeBuiltin()
const char *nm = typeName.constData();
QBENCHMARK {
for (int i = 0; i < 100000; ++i)
- QMetaType::type(nm);
+ QMetaType::fromName(nm);
}
}
@@ -113,7 +87,7 @@ void tst_QMetaType::typeBuiltin_QByteArray()
QFETCH(QByteArray, typeName);
QBENCHMARK {
for (int i = 0; i < 100000; ++i)
- QMetaType::type(typeName);
+ QMetaType::fromName(typeName);
}
}
@@ -121,9 +95,8 @@ void tst_QMetaType::typeBuiltinNotNormalized_data()
{
QTest::addColumn<QByteArray>("typeName");
for (int i = 0; i < QMetaType::User; ++i) {
- const char *name = QMetaType::typeName(i);
- if (name)
- QTest::newRow(name) << QByteArray(name).append(" ");
+ if (QMetaType metaType(i); metaType.isValid())
+ QTest::newRow(metaType.name()) << QByteArray(metaType.name()).append(" ");
}
}
@@ -133,7 +106,7 @@ void tst_QMetaType::typeBuiltinNotNormalized()
const char *nm = typeName.constData();
QBENCHMARK {
for (int i = 0; i < 10000; ++i)
- QMetaType::type(nm);
+ QMetaType::fromName(nm);
}
}
@@ -144,7 +117,7 @@ void tst_QMetaType::typeCustom()
qRegisterMetaType<Foo>("Foo");
QBENCHMARK {
for (int i = 0; i < 10000; ++i)
- QMetaType::type("Foo");
+ QMetaType::fromName("Foo");
}
}
@@ -153,25 +126,25 @@ void tst_QMetaType::typeCustomNotNormalized()
qRegisterMetaType<Foo>("Foo");
QBENCHMARK {
for (int i = 0; i < 10000; ++i)
- QMetaType::type("Foo ");
+ QMetaType::fromName("Foo ");
}
}
void tst_QMetaType::typeNotRegistered()
{
- Q_ASSERT(QMetaType::type("Bar") == 0);
+ Q_ASSERT(!QMetaType::fromName("Bar").isValid());
QBENCHMARK {
for (int i = 0; i < 10000; ++i)
- QMetaType::type("Bar");
+ QMetaType::fromName("Bar");
}
}
void tst_QMetaType::typeNotRegisteredNotNormalized()
{
- Q_ASSERT(QMetaType::type("Bar") == 0);
+ Q_ASSERT(!QMetaType::fromName("Bar").isValid());
QBENCHMARK {
for (int i = 0; i < 10000; ++i)
- QMetaType::type("Bar ");
+ QMetaType::fromName("Bar ");
}
}
@@ -179,9 +152,8 @@ void tst_QMetaType::typeNameBuiltin_data()
{
QTest::addColumn<int>("type");
for (int i = 0; i < QMetaType::User; ++i) {
- const char *name = QMetaType::typeName(i);
- if (name)
- QTest::newRow(name) << i;
+ if (QMetaType metaType(i); metaType.isValid())
+ QTest::newRow(metaType.name()) << i;
}
}
@@ -190,7 +162,7 @@ void tst_QMetaType::typeNameBuiltin()
QFETCH(int, type);
QBENCHMARK {
for (int i = 0; i < 500000; ++i)
- QMetaType::typeName(type);
+ QMetaType(type).name();
}
}
@@ -199,17 +171,17 @@ void tst_QMetaType::typeNameCustom()
int type = qRegisterMetaType<Foo>("Foo");
QBENCHMARK {
for (int i = 0; i < 100000; ++i)
- QMetaType::typeName(type);
+ QMetaType(type).name();
}
}
void tst_QMetaType::typeNameNotRegistered()
{
// We don't care much about this case, but test it anyway.
- Q_ASSERT(QMetaType::typeName(-1) == 0);
+ Q_ASSERT(QMetaType(-1).name() == nullptr);
QBENCHMARK {
for (int i = 0; i < 500000; ++i)
- QMetaType::typeName(-1);
+ QMetaType(-1).name();
}
}
@@ -238,7 +210,7 @@ void tst_QMetaType::isRegisteredCustom()
void tst_QMetaType::isRegisteredNotRegistered()
{
- Q_ASSERT(QMetaType::typeName(-1) == 0);
+ Q_ASSERT(QMetaType(-1).name() == nullptr);
QBENCHMARK {
for (int i = 0; i < 100000; ++i)
QMetaType::isRegistered(-1);
@@ -249,7 +221,7 @@ void tst_QMetaType::constructInPlace_data()
{
QTest::addColumn<int>("typeId");
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
- auto name = QMetaType::typeName(i);
+ auto name = QMetaType(i).name();
if (name && i != QMetaType::Void)
QTest::newRow(name) << i;
}
@@ -261,14 +233,15 @@ void tst_QMetaType::constructInPlace_data()
void tst_QMetaType::constructInPlace()
{
QFETCH(int, typeId);
- int size = QMetaType::sizeOf(typeId);
+ const QMetaType metaType(typeId);
+ size_t size = metaType.sizeOf();
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
- QCOMPARE(QMetaType::construct(typeId, storage, /*copy=*/0), storage);
- QMetaType::destruct(typeId, storage);
+ QCOMPARE(metaType.construct(storage, /*copy=*/0), storage);
+ metaType.destruct(storage);
QBENCHMARK {
for (int i = 0; i < 100000; ++i) {
- QMetaType::construct(typeId, storage, /*copy=*/0);
- QMetaType::destruct(typeId, storage);
+ metaType.construct(storage, /*copy=*/0);
+ metaType.destruct(storage);
}
}
qFreeAligned(storage);
@@ -282,18 +255,19 @@ void tst_QMetaType::constructInPlaceCopy_data()
void tst_QMetaType::constructInPlaceCopy()
{
QFETCH(int, typeId);
- int size = QMetaType::sizeOf(typeId);
+ const QMetaType metaType(typeId);
+ size_t size = metaType.sizeOf();
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
- void *other = QMetaType::create(typeId);
- QCOMPARE(QMetaType::construct(typeId, storage, other), storage);
- QMetaType::destruct(typeId, storage);
+ void *other = metaType.create();
+ QCOMPARE(metaType.construct(storage, other), storage);
+ metaType.destruct(storage);
QBENCHMARK {
for (int i = 0; i < 100000; ++i) {
- QMetaType::construct(typeId, storage, other);
- QMetaType::destruct(typeId, storage);
+ metaType.construct(storage, other);
+ metaType.destruct(storage);
}
}
- QMetaType::destroy(typeId, other);
+ metaType.destroy(other);
qFreeAligned(storage);
}
@@ -305,21 +279,21 @@ void tst_QMetaType::constructInPlaceCopyStaticLess_data()
void tst_QMetaType::constructInPlaceCopyStaticLess()
{
QFETCH(int, typeId);
- int size = QMetaType::sizeOf(typeId);
+ const QMetaType metaType(typeId);
+ size_t size = metaType.sizeOf();
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
- void *other = QMetaType::create(typeId);
- QCOMPARE(QMetaType::construct(typeId, storage, other), storage);
- QMetaType::destruct(typeId, storage);
+ void *other = metaType.create();
+ QCOMPARE(metaType.construct(storage, other), storage);
+ metaType.destruct(storage);
QBENCHMARK {
- QMetaType type(typeId);
for (int i = 0; i < 100000; ++i) {
- type.construct(storage, other);
- type.destruct(storage);
+ metaType.construct(storage, other);
+ metaType.destruct(storage);
}
}
- QMetaType::destroy(typeId, other);
+ metaType.destroy(other);
qFreeAligned(storage);
}
QTEST_MAIN(tst_QMetaType)
-#include "tst_qmetatype.moc"
+#include "tst_bench_qmetatype.moc"
diff --git a/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt
index ce834905b0..15b71f0d60 100644
--- a/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qobject.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qobject Binary:
@@ -6,13 +7,10 @@
qt_internal_add_benchmark(tst_bench_qobject
SOURCES
- main.cpp
+ tst_bench_qobject.cpp
object.cpp object.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Test
Qt::Widgets
)
-
-#### Keys ignored in scope 1:.:.:qobject.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/kernel/qobject/object.cpp b/tests/benchmarks/corelib/kernel/qobject/object.cpp
index 11da3f09c1..9e0fba2e98 100644
--- a/tests/benchmarks/corelib/kernel/qobject/object.cpp
+++ b/tests/benchmarks/corelib/kernel/qobject/object.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "object.h"
void Object::emitSignal0()
diff --git a/tests/benchmarks/corelib/kernel/qobject/object.h b/tests/benchmarks/corelib/kernel/qobject/object.h
index 271c4b9ac6..72705f7f34 100644
--- a/tests/benchmarks/corelib/kernel/qobject/object.h
+++ b/tests/benchmarks/corelib/kernel/qobject/object.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef OBJECT_H
#define OBJECT_H
diff --git a/tests/benchmarks/corelib/kernel/qobject/main.cpp b/tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp
index 918227f74e..99c15f6317 100644
--- a/tests/benchmarks/corelib/kernel/qobject/main.cpp
+++ b/tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <QtWidgets/QTreeView>
#include <qtest.h>
@@ -37,7 +12,7 @@ enum {
SignalsAndSlotsBenchmarkConstant = 456789
};
-class QObjectBenchmark : public QObject
+class tst_QObject : public QObject
{
Q_OBJECT
private slots:
@@ -95,7 +70,7 @@ inline void allocator()
}
}
-void QObjectBenchmark::stdAllocator()
+void tst_QObject::stdAllocator()
{
allocator<QObjectUsingStandardAllocator>();
}
@@ -104,7 +79,7 @@ struct Functor {
void operator()(){}
};
-void QObjectBenchmark::signal_slot_benchmark_data()
+void tst_QObject::signal_slot_benchmark_data()
{
QTest::addColumn<int>("type");
QTest::newRow("simple function") << 0;
@@ -115,7 +90,7 @@ void QObjectBenchmark::signal_slot_benchmark_data()
QTest::newRow("functor") << 5;
}
-void QObjectBenchmark::signal_slot_benchmark()
+void tst_QObject::signal_slot_benchmark()
{
QFETCH(int, type);
@@ -176,7 +151,7 @@ void QObjectBenchmark::signal_slot_benchmark()
}
}
-void QObjectBenchmark::signal_many_receivers_data()
+void tst_QObject::signal_many_receivers_data()
{
QTest::addColumn<int>("receiverCount");
QTest::newRow("100 receivers") << 100;
@@ -184,7 +159,7 @@ void QObjectBenchmark::signal_many_receivers_data()
QTest::newRow("10 000 receivers") << 10000;
}
-void QObjectBenchmark::signal_many_receivers()
+void tst_QObject::signal_many_receivers()
{
QFETCH(int, receiverCount);
Object sender;
@@ -198,7 +173,7 @@ void QObjectBenchmark::signal_many_receivers()
}
}
-void QObjectBenchmark::qproperty_benchmark_data()
+void tst_QObject::qproperty_benchmark_data()
{
QTest::addColumn<QByteArray>("name");
const QMetaObject *mo = &QTreeView::staticMetaObject;
@@ -209,7 +184,7 @@ void QObjectBenchmark::qproperty_benchmark_data()
}
}
-void QObjectBenchmark::qproperty_benchmark()
+void tst_QObject::qproperty_benchmark()
{
QFETCH(QByteArray, name);
const char *p = name.constData();
@@ -221,7 +196,7 @@ void QObjectBenchmark::qproperty_benchmark()
}
}
-void QObjectBenchmark::dynamic_property_benchmark()
+void tst_QObject::dynamic_property_benchmark()
{
QTreeView obj;
QBENCHMARK {
@@ -232,7 +207,7 @@ void QObjectBenchmark::dynamic_property_benchmark()
}
}
-void QObjectBenchmark::connect_disconnect_benchmark_data()
+void tst_QObject::connect_disconnect_benchmark_data()
{
QTest::addColumn<int>("type");
QTest::newRow("normalized signature") << 0;
@@ -243,7 +218,7 @@ void QObjectBenchmark::connect_disconnect_benchmark_data()
QTest::newRow("function pointer/handle") << 5;
QTest::newRow("functor/handle") << 6;}
-void QObjectBenchmark::connect_disconnect_benchmark()
+void tst_QObject::connect_disconnect_benchmark()
{
QFETCH(int, type);
switch (type) {
@@ -296,7 +271,7 @@ void QObjectBenchmark::connect_disconnect_benchmark()
}
}
-void QObjectBenchmark::receiver_destroyed_benchmark()
+void tst_QObject::receiver_destroyed_benchmark()
{
Object sender;
QBENCHMARK {
@@ -305,6 +280,6 @@ void QObjectBenchmark::receiver_destroyed_benchmark()
}
}
-QTEST_MAIN(QObjectBenchmark)
+QTEST_MAIN(tst_QObject)
-#include "main.moc"
+#include "tst_bench_qobject.moc"
diff --git a/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt
index d6fc1c5a14..1a26f28f05 100644
--- a/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt
@@ -1,8 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_benchmark(tst_bench_qproperty
SOURCES
- main.cpp
+ tst_bench_qproperty.cpp
propertytester.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Test
)
diff --git a/tests/benchmarks/corelib/kernel/qproperty/propertytester.h b/tests/benchmarks/corelib/kernel/qproperty/propertytester.h
index daf55f8396..a89d51c286 100644
--- a/tests/benchmarks/corelib/kernel/qproperty/propertytester.h
+++ b/tests/benchmarks/corelib/kernel/qproperty/propertytester.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PROPERTYTESTER_H
#define PROPERTYTESTER_H
diff --git a/tests/benchmarks/corelib/kernel/qproperty/main.cpp b/tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp
index 5d6db35d2b..c91ca1ea11 100644
--- a/tests/benchmarks/corelib/kernel/qproperty/main.cpp
+++ b/tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QScopedPointer>
#include <QProperty>
@@ -33,7 +8,7 @@
#include "propertytester.h"
-class PropertyBenchmark : public QObject
+class tst_QProperty : public QObject
{
Q_OBJECT
private slots:
@@ -53,7 +28,7 @@ private slots:
void cppNotifyingDirectReadOnce();
};
-void PropertyBenchmark::cppOldBinding()
+void tst_QProperty::cppOldBinding()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
auto connection = connect(tester.data(), &PropertyTester::xOldChanged,
@@ -70,7 +45,7 @@ void PropertyBenchmark::cppOldBinding()
QObject::disconnect(connection);
}
-void PropertyBenchmark::cppOldBindingDirect()
+void tst_QProperty::cppOldBindingDirect()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
auto connection = connect(tester.data(), &PropertyTester::xOldChanged,
@@ -87,7 +62,7 @@ void PropertyBenchmark::cppOldBindingDirect()
QObject::disconnect(connection);
}
-void PropertyBenchmark::cppOldBindingReadOnce()
+void tst_QProperty::cppOldBindingReadOnce()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
auto connection = connect(tester.data(), &PropertyTester::xOldChanged,
@@ -103,7 +78,7 @@ void PropertyBenchmark::cppOldBindingReadOnce()
QObject::disconnect(connection);
}
-void PropertyBenchmark::cppOldBindingDirectReadOnce()
+void tst_QProperty::cppOldBindingDirectReadOnce()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
auto connection = connect(tester.data(), &PropertyTester::xOldChanged,
@@ -119,7 +94,7 @@ void PropertyBenchmark::cppOldBindingDirectReadOnce()
QObject::disconnect(connection);
}
-void PropertyBenchmark::cppNewBinding()
+void tst_QProperty::cppNewBinding()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->y.setBinding([&](){return tester->x.value();});
@@ -133,7 +108,7 @@ void PropertyBenchmark::cppNewBinding()
}
}
-void PropertyBenchmark::cppNewBindingDirect()
+void tst_QProperty::cppNewBindingDirect()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->y.setBinding([&](){return tester->x.value();});
@@ -146,7 +121,7 @@ void PropertyBenchmark::cppNewBindingDirect()
}
}
-void PropertyBenchmark::cppNewBindingReadOnce()
+void tst_QProperty::cppNewBindingReadOnce()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->y.setBinding([&](){return tester->x.value();});
@@ -160,7 +135,7 @@ void PropertyBenchmark::cppNewBindingReadOnce()
QCOMPARE(tester->property("y").toInt(), i);
}
-void PropertyBenchmark::cppNewBindingDirectReadOnce()
+void tst_QProperty::cppNewBindingDirectReadOnce()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->y.setBinding([&](){return tester->x.value();});
@@ -173,7 +148,7 @@ void PropertyBenchmark::cppNewBindingDirectReadOnce()
QCOMPARE(tester->y.value(), i);
}
-void PropertyBenchmark::cppNotifying()
+void tst_QProperty::cppNotifying()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->yNotified.setBinding([&](){return tester->xNotified.value();});
@@ -187,7 +162,7 @@ void PropertyBenchmark::cppNotifying()
}
}
-void PropertyBenchmark::cppNotifyingDirect()
+void tst_QProperty::cppNotifyingDirect()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->yNotified.setBinding([&](){return tester->xNotified.value();});
@@ -200,7 +175,7 @@ void PropertyBenchmark::cppNotifyingDirect()
}
}
-void PropertyBenchmark::cppNotifyingReadOnce()
+void tst_QProperty::cppNotifyingReadOnce()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->yNotified.setBinding([&](){return tester->xNotified.value();});
@@ -214,7 +189,7 @@ void PropertyBenchmark::cppNotifyingReadOnce()
QCOMPARE(tester->property("yNotified").toInt(), i);
}
-void PropertyBenchmark::cppNotifyingDirectReadOnce()
+void tst_QProperty::cppNotifyingDirectReadOnce()
{
QScopedPointer<PropertyTester> tester {new PropertyTester};
tester->yNotified.setBinding([&](){return tester->xNotified.value();});
@@ -227,5 +202,6 @@ void PropertyBenchmark::cppNotifyingDirectReadOnce()
QCOMPARE(tester->yNotified.value(), i);
}
-QTEST_MAIN(PropertyBenchmark)
-#include "main.moc"
+QTEST_MAIN(tst_QProperty)
+
+#include "tst_bench_qproperty.moc"
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt
index 5ba14e43a2..22e04d98a2 100644
--- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qtimer_vs_qmetaobject.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## qtimer_vs_qmetaobject Binary:
@@ -9,9 +10,6 @@ qt_internal_add_benchmark(qtimer_vs_qmetaobject
tst_qtimer_vs_qmetaobject.cpp
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qtimer_vs_qmetaobject.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
index 52a726b292..d0b3e21772 100644
--- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <QTest>
@@ -126,13 +101,9 @@ void qtimer_vs_qmetaobject::bench_data()
void qtimer_vs_qmetaobject::benchBackgroundThread()
{
-#if !QT_CONFIG(cxx11_future)
- QSKIP("This test requires QThread::create");
-#else
QScopedPointer<QThread> thread(QThread::create([this]() { bench(); }));
thread->start();
QVERIFY(thread->wait());
-#endif
}
QTEST_MAIN(qtimer_vs_qmetaobject)
diff --git a/tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt
index 418fd1da9f..07978956b1 100644
--- a/tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qvariant.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qvariant Binary:
@@ -6,16 +7,15 @@
qt_internal_add_benchmark(tst_bench_qvariant
SOURCES
- tst_qvariant.cpp
- PUBLIC_LIBRARIES
- Qt::Gui
+ tst_bench_qvariant.cpp
+ LIBRARIES
Qt::Test
)
## Scopes:
#####################################################################
-qt_internal_extend_target(tst_bench_qvariant CONDITION NOT TARGET Qt::Gui
- PUBLIC_LIBRARIES
- # Remove: gui
+qt_internal_extend_target(tst_bench_qvariant CONDITION TARGET Qt::Gui
+ LIBRARIES
+ Qt::Gui
)
diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp
index 9664143608..8b2e10c125 100644
--- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#ifdef QT_GUI_LIB
@@ -34,7 +9,7 @@
#define ITERATION_COUNT 1e5
-class tst_qvariant : public QObject
+class tst_QVariant : public QObject
{
Q_OBJECT
@@ -107,7 +82,7 @@ Q_DECLARE_TYPEINFO(SmallClass, Q_RELOCATABLE_TYPE);
QT_END_NAMESPACE
Q_DECLARE_METATYPE(SmallClass);
-void tst_qvariant::testBound()
+void tst_QVariant::testBound()
{
qreal d = qreal(.5);
QBENCHMARK {
@@ -148,7 +123,7 @@ void variantCreation<SmallClass>(SmallClass val)
}
template <>
-void variantCreation<tst_qvariant::ABenchmarkEnum>(tst_qvariant::ABenchmarkEnum val)
+void variantCreation<tst_QVariant::ABenchmarkEnum>(tst_QVariant::ABenchmarkEnum val)
{
QBENCHMARK {
for (int i = 0; i < ITERATION_COUNT; ++i) {
@@ -158,49 +133,49 @@ void variantCreation<tst_qvariant::ABenchmarkEnum>(tst_qvariant::ABenchmarkEnum
}
-void tst_qvariant::doubleVariantCreation()
+void tst_QVariant::doubleVariantCreation()
{
variantCreation<double>(0.0);
}
-void tst_qvariant::floatVariantCreation()
+void tst_QVariant::floatVariantCreation()
{
variantCreation<float>(0.0f);
}
-void tst_qvariant::rectVariantCreation()
+void tst_QVariant::rectVariantCreation()
{
variantCreation<QRect>(QRect(1, 2, 3, 4));
}
-void tst_qvariant::stringVariantCreation()
+void tst_QVariant::stringVariantCreation()
{
variantCreation<QString>(QString());
}
#ifdef QT_GUI_LIB
-void tst_qvariant::pixmapVariantCreation()
+void tst_QVariant::pixmapVariantCreation()
{
variantCreation<QPixmap>(QPixmap());
}
#endif
-void tst_qvariant::stringListVariantCreation()
+void tst_QVariant::stringListVariantCreation()
{
variantCreation<QStringList>(QStringList());
}
-void tst_qvariant::bigClassVariantCreation()
+void tst_QVariant::bigClassVariantCreation()
{
variantCreation<BigClass>(BigClass());
}
-void tst_qvariant::smallClassVariantCreation()
+void tst_QVariant::smallClassVariantCreation()
{
variantCreation<SmallClass>(SmallClass());
}
-void tst_qvariant::enumVariantCreation()
+void tst_QVariant::enumVariantCreation()
{
variantCreation<ABenchmarkEnum>(FirstEnumValue);
}
@@ -217,42 +192,42 @@ static void variantSetValue(T d)
}
}
-void tst_qvariant::doubleVariantSetValue()
+void tst_QVariant::doubleVariantSetValue()
{
variantSetValue<double>(0.0);
}
-void tst_qvariant::floatVariantSetValue()
+void tst_QVariant::floatVariantSetValue()
{
variantSetValue<float>(0.0f);
}
-void tst_qvariant::rectVariantSetValue()
+void tst_QVariant::rectVariantSetValue()
{
variantSetValue<QRect>(QRect());
}
-void tst_qvariant::stringVariantSetValue()
+void tst_QVariant::stringVariantSetValue()
{
variantSetValue<QString>(QString());
}
-void tst_qvariant::stringListVariantSetValue()
+void tst_QVariant::stringListVariantSetValue()
{
variantSetValue<QStringList>(QStringList());
}
-void tst_qvariant::bigClassVariantSetValue()
+void tst_QVariant::bigClassVariantSetValue()
{
variantSetValue<BigClass>(BigClass());
}
-void tst_qvariant::smallClassVariantSetValue()
+void tst_QVariant::smallClassVariantSetValue()
{
variantSetValue<SmallClass>(SmallClass());
}
-void tst_qvariant::enumVariantSetValue()
+void tst_QVariant::enumVariantSetValue()
{
variantSetValue<ABenchmarkEnum>(FirstEnumValue);
}
@@ -268,32 +243,32 @@ static void variantAssignment(T d)
}
}
-void tst_qvariant::doubleVariantAssignment()
+void tst_QVariant::doubleVariantAssignment()
{
variantAssignment<double>(0.0);
}
-void tst_qvariant::floatVariantAssignment()
+void tst_QVariant::floatVariantAssignment()
{
variantAssignment<float>(0.0f);
}
-void tst_qvariant::rectVariantAssignment()
+void tst_QVariant::rectVariantAssignment()
{
variantAssignment<QRect>(QRect());
}
-void tst_qvariant::stringVariantAssignment()
+void tst_QVariant::stringVariantAssignment()
{
variantAssignment<QString>(QString());
}
-void tst_qvariant::stringListVariantAssignment()
+void tst_QVariant::stringListVariantAssignment()
{
variantAssignment<QStringList>(QStringList());
}
-void tst_qvariant::doubleVariantValue()
+void tst_QVariant::doubleVariantValue()
{
QVariant v(0.0);
QBENCHMARK {
@@ -303,7 +278,7 @@ void tst_qvariant::doubleVariantValue()
}
}
-void tst_qvariant::floatVariantValue()
+void tst_QVariant::floatVariantValue()
{
QVariant v(0.0f);
QBENCHMARK {
@@ -313,7 +288,7 @@ void tst_qvariant::floatVariantValue()
}
}
-void tst_qvariant::rectVariantValue()
+void tst_QVariant::rectVariantValue()
{
QVariant v(QRect(1,2,3,4));
QBENCHMARK {
@@ -323,7 +298,7 @@ void tst_qvariant::rectVariantValue()
}
}
-void tst_qvariant::stringVariantValue()
+void tst_QVariant::stringVariantValue()
{
QVariant v = QString();
QBENCHMARK {
@@ -333,12 +308,12 @@ void tst_qvariant::stringVariantValue()
}
}
-void tst_qvariant::createCoreType_data()
+void tst_QVariant::createCoreType_data()
{
QTest::addColumn<int>("typeId");
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
- if (QMetaType::typeName(i)) // QMetaType(27) does not exist
- QTest::newRow(QMetaType::typeName(i)) << i;
+ if (QMetaType metaType(i); metaType.isValid()) // QMetaType(27) does not exist
+ QTest::newRow(metaType.name()) << i;
}
}
@@ -346,7 +321,7 @@ void tst_qvariant::createCoreType_data()
// QVariant. The purpose of this benchmark is to measure the overhead
// of creating (and destroying) a QVariant compared to creating the
// type directly.
-void tst_qvariant::createCoreType()
+void tst_QVariant::createCoreType()
{
QFETCH(int, typeId);
QBENCHMARK {
@@ -355,7 +330,7 @@ void tst_qvariant::createCoreType()
}
}
-void tst_qvariant::createCoreTypeCopy_data()
+void tst_QVariant::createCoreTypeCopy_data()
{
createCoreType_data();
}
@@ -364,7 +339,7 @@ void tst_qvariant::createCoreTypeCopy_data()
// QVariant. The purpose of this benchmark is to measure the overhead
// of creating (and destroying) a QVariant compared to creating the
// type directly.
-void tst_qvariant::createCoreTypeCopy()
+void tst_QVariant::createCoreTypeCopy()
{
QFETCH(int, typeId);
QMetaType metaType(typeId);
@@ -376,6 +351,6 @@ void tst_qvariant::createCoreTypeCopy()
}
}
-QTEST_MAIN(tst_qvariant)
+QTEST_MAIN(tst_QVariant)
-#include "tst_qvariant.moc"
+#include "tst_bench_qvariant.moc"
diff --git a/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt
index a581b1eaef..e78d3250bc 100644
--- a/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qwineventnotifier.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qwineventnotifier Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_qwineventnotifier
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qwineventnotifier.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qwineventnotifier.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/kernel/qwineventnotifier/main.cpp b/tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp
index 926ed5acdb..b1f87eabed 100644
--- a/tests/benchmarks/corelib/kernel/qwineventnotifier/main.cpp
+++ b/tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtCore/qglobal.h>
@@ -34,7 +9,7 @@
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qt_windows.h>
-class QWinEventNotifierBenchmark : public QObject
+class tst_QWinEventNotifier : public QObject
{
Q_OBJECT
@@ -102,7 +77,7 @@ protected:
int numberOfIterations;
};
-void QWinEventNotifierBenchmark::waves_data()
+void tst_QWinEventNotifier::waves_data()
{
QTest::addColumn<int>("waves");
QTest::addColumn<int>("notifiers");
@@ -112,7 +87,7 @@ void QWinEventNotifierBenchmark::waves_data()
}
}
-void QWinEventNotifierBenchmark::waves()
+void tst_QWinEventNotifier::waves()
{
QFETCH(int, waves);
QFETCH(int, notifiers);
@@ -131,6 +106,6 @@ void QWinEventNotifierBenchmark::waves()
emit factory.stop();
}
-QTEST_MAIN(QWinEventNotifierBenchmark)
+QTEST_MAIN(tst_QWinEventNotifier)
-#include "main.moc"
+#include "tst_bench_qwineventnotifier.moc"