Add benchmarks for QMetaType::construct()
Change-Id: Ia5883c5712e5d634b0e62189b639209eb3d5cd93 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
This commit is contained in:
parent
9e92ecde74
commit
f8b89fa507
@ -76,6 +76,11 @@ private slots:
|
|||||||
void constructCoreType();
|
void constructCoreType();
|
||||||
void constructCoreTypeCopy_data();
|
void constructCoreTypeCopy_data();
|
||||||
void constructCoreTypeCopy();
|
void constructCoreTypeCopy();
|
||||||
|
|
||||||
|
void constructInPlace_data();
|
||||||
|
void constructInPlace();
|
||||||
|
void constructInPlaceCopy_data();
|
||||||
|
void constructInPlaceCopy();
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QMetaType::tst_QMetaType()
|
tst_QMetaType::tst_QMetaType()
|
||||||
@ -281,5 +286,49 @@ void tst_QMetaType::constructCoreTypeCopy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMetaType::constructInPlace_data()
|
||||||
|
{
|
||||||
|
constructCoreType_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QMetaType::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_QMetaType::constructInPlaceCopy_data()
|
||||||
|
{
|
||||||
|
constructCoreType_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QMetaType::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_QMetaType)
|
QTEST_MAIN(tst_QMetaType)
|
||||||
#include "tst_qmetatype.moc"
|
#include "tst_qmetatype.moc"
|
||||||
|
@ -55,6 +55,11 @@ private slots:
|
|||||||
void constructGuiType();
|
void constructGuiType();
|
||||||
void constructGuiTypeCopy_data();
|
void constructGuiTypeCopy_data();
|
||||||
void constructGuiTypeCopy();
|
void constructGuiTypeCopy();
|
||||||
|
|
||||||
|
void constructInPlace_data();
|
||||||
|
void constructInPlace();
|
||||||
|
void constructInPlaceCopy_data();
|
||||||
|
void constructInPlaceCopy();
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QGuiMetaType::tst_QGuiMetaType()
|
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)
|
QTEST_MAIN(tst_QGuiMetaType)
|
||||||
#include "tst_qguimetatype.moc"
|
#include "tst_qguimetatype.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user