diff options
Diffstat (limited to 'tests/benchmarks/corelib/kernel')
-rw-r--r-- | tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp | 56 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp | 4 |
2 files changed, 57 insertions, 3 deletions
diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp index 14895863e4..a3cdd38e56 100644 --- a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -72,6 +72,8 @@ private slots: void constructCoreType_data(); void constructCoreType(); + void constructCoreTypeStaticLess_data(); + void constructCoreTypeStaticLess(); void constructCoreTypeCopy_data(); void constructCoreTypeCopy(); @@ -79,6 +81,8 @@ private slots: void constructInPlace(); void constructInPlaceCopy_data(); void constructInPlaceCopy(); + void constructInPlaceCopyStaticLess_data(); + void constructInPlaceCopyStaticLess(); }; tst_QMetaType::tst_QMetaType() @@ -89,6 +93,12 @@ tst_QMetaType::~tst_QMetaType() { } +struct BigClass +{ + double n,i,e,r,o,b; +}; +Q_DECLARE_METATYPE(BigClass); + void tst_QMetaType::typeBuiltin_data() { QTest::addColumn<QByteArray>("typeName"); @@ -240,7 +250,7 @@ void tst_QMetaType::isRegisteredNotRegistered() void tst_QMetaType::constructCoreType_data() { QTest::addColumn<int>("typeId"); - for (int i = 0; i <= QMetaType::LastCoreType; ++i) + for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) QTest::newRow(QMetaType::typeName(i)) << i; // GUI types are tested in tst_QGuiMetaType. } @@ -260,6 +270,23 @@ void tst_QMetaType::constructCoreType() } } +void tst_QMetaType::constructCoreTypeStaticLess_data() +{ + constructCoreType_data(); +} + +void tst_QMetaType::constructCoreTypeStaticLess() +{ + QFETCH(int, typeId); + QBENCHMARK { + QMetaType type(typeId); + for (int i = 0; i < 100000; ++i) { + void *data = type.create((void *)0); + type.destroy(data); + } + } +} + void tst_QMetaType::constructCoreTypeCopy_data() { constructCoreType_data(); @@ -285,6 +312,7 @@ void tst_QMetaType::constructCoreTypeCopy() void tst_QMetaType::constructInPlace_data() { constructCoreType_data(); + QTest::newRow("custom") << qMetaTypeId<BigClass>(); } void tst_QMetaType::constructInPlace() @@ -305,7 +333,7 @@ void tst_QMetaType::constructInPlace() void tst_QMetaType::constructInPlaceCopy_data() { - constructCoreType_data(); + constructInPlace_data(); } void tst_QMetaType::constructInPlaceCopy() @@ -326,5 +354,29 @@ void tst_QMetaType::constructInPlaceCopy() qFreeAligned(storage); } +void tst_QMetaType::constructInPlaceCopyStaticLess_data() +{ + constructInPlaceCopy_data(); +} + +void tst_QMetaType::constructInPlaceCopyStaticLess() +{ + QFETCH(int, typeId); + int size = QMetaType::sizeOf(typeId); + void *storage = qMallocAligned(size, 2 * sizeof(qlonglong)); + void *other = QMetaType::create(typeId); + QCOMPARE(QMetaType::construct(typeId, storage, other), storage); + QMetaType::destruct(typeId, storage); + QBENCHMARK { + QMetaType type(typeId); + for (int i = 0; i < 100000; ++i) { + type.construct(storage, other); + type.destruct(storage); + } + } + QMetaType::destroy(typeId, other); + qFreeAligned(storage); +} + QTEST_MAIN(tst_QMetaType) #include "tst_qmetatype.moc" diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp index 0c4af17376..f6b4d88311 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp @@ -90,6 +90,7 @@ struct BigClass double n,i,e,r,o,b; }; Q_STATIC_ASSERT(sizeof(BigClass) > sizeof(QVariant::Private::Data)); +Q_DECLARE_TYPEINFO(BigClass, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(BigClass); struct SmallClass @@ -97,6 +98,7 @@ struct SmallClass char s; }; Q_STATIC_ASSERT(sizeof(SmallClass) <= sizeof(QVariant::Private::Data)); +Q_DECLARE_TYPEINFO(SmallClass, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(SmallClass); void tst_qvariant::testBound() @@ -305,7 +307,7 @@ void tst_qvariant::stringVariantValue() void tst_qvariant::createCoreType_data() { QTest::addColumn<int>("typeId"); - for (int i = 0; i <= QMetaType::LastCoreType; ++i) + for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) QTest::newRow(QMetaType::typeName(i)) << i; } |