diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp index f1c49c3af5..85d14b99b6 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp @@ -56,16 +56,23 @@ private slots: void rectVariantCreation(); void stringVariantCreation(); void pixmapVariantCreation(); + void stringListVariantCreation(); + void bigClassVariantCreation(); + void smallClassVariantCreation(); void doubleVariantSetValue(); void floatVariantSetValue(); void rectVariantSetValue(); void stringVariantSetValue(); + void stringListVariantSetValue(); + void bigClassVariantSetValue(); + void smallClassVariantSetValue(); void doubleVariantAssignment(); void floatVariantAssignment(); void rectVariantAssignment(); void stringVariantAssignment(); + void stringListVariantAssignment(); void doubleVariantValue(); void floatVariantValue(); @@ -78,6 +85,20 @@ private slots: void createCoreTypeCopy(); }; +struct BigClass +{ + double n,i,e,r,o,b; +}; +Q_STATIC_ASSERT(sizeof(BigClass) > sizeof(QVariant::Private::Data)); +Q_DECLARE_METATYPE(BigClass); + +struct SmallClass +{ + char s; +}; +Q_STATIC_ASSERT(sizeof(SmallClass) <= sizeof(QVariant::Private::Data)); +Q_DECLARE_METATYPE(SmallClass); + void tst_qvariant::testBound() { qreal d = qreal(.5); @@ -98,6 +119,27 @@ static void variantCreation(T val) } } +template <> +void variantCreation(BigClass val) +{ + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) { + QVariant::fromValue(val); + } + } +} + +template <> +void variantCreation(SmallClass val) +{ + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) { + QVariant::fromValue(val); + } + } +} + + void tst_qvariant::doubleVariantCreation() { variantCreation(0.0); @@ -123,6 +165,21 @@ void tst_qvariant::pixmapVariantCreation() variantCreation(QPixmap()); } +void tst_qvariant::stringListVariantCreation() +{ + variantCreation(QStringList()); +} + +void tst_qvariant::bigClassVariantCreation() +{ + variantCreation(BigClass()); +} + +void tst_qvariant::smallClassVariantCreation() +{ + variantCreation(SmallClass()); +} + template static void variantSetValue(T d) { @@ -154,6 +211,21 @@ void tst_qvariant::stringVariantSetValue() variantSetValue(QString()); } +void tst_qvariant::stringListVariantSetValue() +{ + variantSetValue(QStringList()); +} + +void tst_qvariant::bigClassVariantSetValue() +{ + variantSetValue(BigClass()); +} + +void tst_qvariant::smallClassVariantSetValue() +{ + variantSetValue(SmallClass()); +} + template static void variantAssignment(T d) { @@ -185,6 +257,11 @@ void tst_qvariant::stringVariantAssignment() variantAssignment(QString()); } +void tst_qvariant::stringListVariantAssignment() +{ + variantAssignment(QStringList()); +} + void tst_qvariant::doubleVariantValue() { QVariant v(0.0);