From 9004a2412ba1f9976c2c61f01223dff852208c42 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 18 Aug 2021 11:48:29 +0200 Subject: Standardise layout and naming in corelib benchmarks Make file names match CMake's test names (and those follow dir-name) and class names follow tst_ClassName pattern when testing ClassName. Purge comments about the qmake configs the CMakeLists.txt are generated from. Purge empty constructors and init/cleanup methods of classes. Fix petty coding style violations. Add qdir/tree/, qurl, qbench and qset benchmarks to their parent directories' lists of subdirs. Fix unused return error from qurl benchmark. Change-Id: Ifc15a3a46e71cf82ad0637753517e0df34049763 Reviewed-by: Andrei Golubev Reviewed-by: Thiago Macieira --- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 324 --------------------- 1 file changed, 324 deletions(-) delete mode 100644 tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp (limited to 'tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp') diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp deleted file mode 100644 index d41823de71..0000000000 --- a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include -#include - -class tst_QMetaType : public QObject -{ - Q_OBJECT - -public: - tst_QMetaType(); - virtual ~tst_QMetaType(); - -private slots: - void typeBuiltin_data(); - void typeBuiltin(); - void typeBuiltin_QByteArray_data(); - void typeBuiltin_QByteArray(); - void typeBuiltinNotNormalized_data(); - void typeBuiltinNotNormalized(); - void typeCustom(); - void typeCustomNotNormalized(); - void typeNotRegistered(); - void typeNotRegisteredNotNormalized(); - - void typeNameBuiltin_data(); - void typeNameBuiltin(); - void typeNameCustom(); - void typeNameNotRegistered(); - - void isRegisteredBuiltin_data(); - void isRegisteredBuiltin(); - void isRegisteredCustom(); - void isRegisteredNotRegistered(); - - void constructInPlace_data(); - void constructInPlace(); - void constructInPlaceCopy_data(); - void constructInPlaceCopy(); - void constructInPlaceCopyStaticLess_data(); - void constructInPlaceCopyStaticLess(); -}; - -tst_QMetaType::tst_QMetaType() -{ -} - -tst_QMetaType::~tst_QMetaType() -{ -} - -struct BigClass -{ - double n,i,e,r,o,b; -}; -Q_DECLARE_METATYPE(BigClass); - -void tst_QMetaType::typeBuiltin_data() -{ - QTest::addColumn("typeName"); - for (int i = 0; i < QMetaType::User; ++i) { - if (QMetaType metaType(i); metaType.isValid()) - QTest::newRow(metaType.name()) << QByteArray(metaType.name()); - } -} - -// QMetaType::type(const char *) -void tst_QMetaType::typeBuiltin() -{ - QFETCH(QByteArray, typeName); - const char *nm = typeName.constData(); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) - QMetaType::fromName(nm); - } -} - -void tst_QMetaType::typeBuiltin_QByteArray_data() -{ - typeBuiltin_data(); -} - -// QMetaType::type(QByteArray) -void tst_QMetaType::typeBuiltin_QByteArray() -{ - QFETCH(QByteArray, typeName); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) - QMetaType::fromName(typeName); - } -} - -void tst_QMetaType::typeBuiltinNotNormalized_data() -{ - QTest::addColumn("typeName"); - for (int i = 0; i < QMetaType::User; ++i) { - if (QMetaType metaType(i); metaType.isValid()) - QTest::newRow(metaType.name()) << QByteArray(metaType.name()).append(" "); - } -} - -void tst_QMetaType::typeBuiltinNotNormalized() -{ - QFETCH(QByteArray, typeName); - const char *nm = typeName.constData(); - QBENCHMARK { - for (int i = 0; i < 10000; ++i) - QMetaType::fromName(nm); - } -} - -struct Foo { int i; }; - -void tst_QMetaType::typeCustom() -{ - qRegisterMetaType("Foo"); - QBENCHMARK { - for (int i = 0; i < 10000; ++i) - QMetaType::fromName("Foo"); - } -} - -void tst_QMetaType::typeCustomNotNormalized() -{ - qRegisterMetaType("Foo"); - QBENCHMARK { - for (int i = 0; i < 10000; ++i) - QMetaType::fromName("Foo "); - } -} - -void tst_QMetaType::typeNotRegistered() -{ - Q_ASSERT(!QMetaType::fromName("Bar").isValid()); - QBENCHMARK { - for (int i = 0; i < 10000; ++i) - QMetaType::fromName("Bar"); - } -} - -void tst_QMetaType::typeNotRegisteredNotNormalized() -{ - Q_ASSERT(!QMetaType::fromName("Bar").isValid()); - QBENCHMARK { - for (int i = 0; i < 10000; ++i) - QMetaType::fromName("Bar "); - } -} - -void tst_QMetaType::typeNameBuiltin_data() -{ - QTest::addColumn("type"); - for (int i = 0; i < QMetaType::User; ++i) { - if (QMetaType metaType(i); metaType.isValid()) - QTest::newRow(metaType.name()) << i; - } -} - -void tst_QMetaType::typeNameBuiltin() -{ - QFETCH(int, type); - QBENCHMARK { - for (int i = 0; i < 500000; ++i) - QMetaType(type).name(); - } -} - -void tst_QMetaType::typeNameCustom() -{ - int type = qRegisterMetaType("Foo"); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) - QMetaType(type).name(); - } -} - -void tst_QMetaType::typeNameNotRegistered() -{ - // We don't care much about this case, but test it anyway. - Q_ASSERT(QMetaType(-1).name() == nullptr); - QBENCHMARK { - for (int i = 0; i < 500000; ++i) - QMetaType(-1).name(); - } -} - -void tst_QMetaType::isRegisteredBuiltin_data() -{ - typeNameBuiltin_data(); -} - -void tst_QMetaType::isRegisteredBuiltin() -{ - QFETCH(int, type); - QBENCHMARK { - for (int i = 0; i < 500000; ++i) - QMetaType::isRegistered(type); - } -} - -void tst_QMetaType::isRegisteredCustom() -{ - int type = qRegisterMetaType("Foo"); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) - QMetaType::isRegistered(type); - } -} - -void tst_QMetaType::isRegisteredNotRegistered() -{ - Q_ASSERT(QMetaType(-1).name() == nullptr); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) - QMetaType::isRegistered(-1); - } -} - -void tst_QMetaType::constructInPlace_data() -{ - QTest::addColumn("typeId"); - for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) { - auto name = QMetaType(i).name(); - if (name && i != QMetaType::Void) - QTest::newRow(name) << i; - } - - QTest::newRow("custom") << qMetaTypeId(); - // GUI types are tested in tst_QGuiMetaType. -} - -void tst_QMetaType::constructInPlace() -{ - QFETCH(int, typeId); - const QMetaType metaType(typeId); - size_t size = metaType.sizeOf(); - void *storage = qMallocAligned(size, 2 * sizeof(qlonglong)); - QCOMPARE(metaType.construct(storage, /*copy=*/0), storage); - metaType.destruct(storage); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) { - metaType.construct(storage, /*copy=*/0); - metaType.destruct(storage); - } - } - qFreeAligned(storage); -} - -void tst_QMetaType::constructInPlaceCopy_data() -{ - constructInPlace_data(); -} - -void tst_QMetaType::constructInPlaceCopy() -{ - QFETCH(int, typeId); - const QMetaType metaType(typeId); - size_t size = metaType.sizeOf(); - void *storage = qMallocAligned(size, 2 * sizeof(qlonglong)); - void *other = metaType.create(); - QCOMPARE(metaType.construct(storage, other), storage); - metaType.destruct(storage); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) { - metaType.construct(storage, other); - metaType.destruct(storage); - } - } - metaType.destroy(other); - qFreeAligned(storage); -} - -void tst_QMetaType::constructInPlaceCopyStaticLess_data() -{ - constructInPlaceCopy_data(); -} - -void tst_QMetaType::constructInPlaceCopyStaticLess() -{ - QFETCH(int, typeId); - const QMetaType metaType(typeId); - size_t size = metaType.sizeOf(); - void *storage = qMallocAligned(size, 2 * sizeof(qlonglong)); - void *other = metaType.create(); - QCOMPARE(metaType.construct(storage, other), storage); - metaType.destruct(storage); - QBENCHMARK { - for (int i = 0; i < 100000; ++i) { - metaType.construct(storage, other); - metaType.destruct(storage); - } - } - metaType.destroy(other); - qFreeAligned(storage); -} - -QTEST_MAIN(tst_QMetaType) -#include "tst_qmetatype.moc" -- cgit v1.2.3