diff options
Diffstat (limited to 'tests/benchmarks/corelib/kernel/qvariant')
-rw-r--r-- | tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp (renamed from tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp) | 103 |
2 files changed, 46 insertions, 71 deletions
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" |