summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/gui
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-10-10 14:33:56 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-19 10:25:31 +0200
commitf8b89fa50725a8d25c76bbf96e622e061d3417a4 (patch)
tree83f7c673023454ae741b0871f54e4fa421eae6db /tests/benchmarks/gui
parent9e92ecde74d33eddd39de88472964fb20feaaebf (diff)
Add benchmarks for QMetaType::construct()
Change-Id: Ia5883c5712e5d634b0e62189b639209eb3d5cd93 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'tests/benchmarks/gui')
-rw-r--r--tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp
index b92c26ad7d..1d0a2d9330 100644
--- a/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp
+++ b/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp
@@ -55,6 +55,11 @@ private slots:
void constructGuiType();
void constructGuiTypeCopy_data();
void constructGuiTypeCopy();
+
+ void constructInPlace_data();
+ void constructInPlace();
+ void constructInPlaceCopy_data();
+ void constructInPlaceCopy();
};
tst_QGuiMetaType::tst_QGuiMetaType()
@@ -109,5 +114,49 @@ void tst_QGuiMetaType::constructGuiTypeCopy()
}
}
+void tst_QGuiMetaType::constructInPlace_data()
+{
+ constructGuiType_data();
+}
+
+void tst_QGuiMetaType::constructInPlace()
+{
+ QFETCH(int, typeId);
+ int size = QMetaType::sizeOf(typeId);
+ void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
+ QCOMPARE(QMetaType::construct(typeId, storage, /*copy=*/0), storage);
+ QMetaType::destruct(typeId, storage);
+ QBENCHMARK {
+ for (int i = 0; i < 100000; ++i) {
+ QMetaType::construct(typeId, storage, /*copy=*/0);
+ QMetaType::destruct(typeId, storage);
+ }
+ }
+ qFreeAligned(storage);
+}
+
+void tst_QGuiMetaType::constructInPlaceCopy_data()
+{
+ constructGuiType_data();
+}
+
+void tst_QGuiMetaType::constructInPlaceCopy()
+{
+ 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 {
+ for (int i = 0; i < 100000; ++i) {
+ QMetaType::construct(typeId, storage, other);
+ QMetaType::destruct(typeId, storage);
+ }
+ }
+ QMetaType::destroy(typeId, other);
+ qFreeAligned(storage);
+}
+
QTEST_MAIN(tst_QGuiMetaType)
#include "tst_qguimetatype.moc"