Add benchmark for QMetaType::create().
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>
Tue, 6 Mar 2012 11:04:37 +0000 (12:04 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 6 Mar 2012 23:10:15 +0000 (00:10 +0100)
A case of a custom type creation was not covered before.

Change-Id: Icd2a7d63633f8e40d9d4a8a26e0eb0896fc85ec8
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp

index a3cdd38..c80a946 100644 (file)
@@ -77,6 +77,9 @@ private slots:
     void constructCoreTypeCopy_data();
     void constructCoreTypeCopy();
 
+    void constructCustomType_data();
+    void constructCustomType();
+
     void constructInPlace_data();
     void constructInPlace();
     void constructInPlaceCopy_data();
@@ -309,6 +312,24 @@ void tst_QMetaType::constructCoreTypeCopy()
     }
 }
 
+void tst_QMetaType::constructCustomType_data()
+{
+    QTest::addColumn<int>("typeId");
+
+    QTest::newRow("BigClass") << qMetaTypeId<BigClass>();
+}
+
+void tst_QMetaType::constructCustomType()
+{
+    QFETCH(int, typeId);
+    QBENCHMARK {
+        for (int i = 0; i < 100000; ++i) {
+            void *data = QMetaType::create(typeId, (void *)0);
+            QMetaType::destroy(typeId, data);
+        }
+    }
+}
+
 void tst_QMetaType::constructInPlace_data()
 {
     constructCoreType_data();