diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 2 | ||||
-rw-r--r-- | tests/benchmarks/qml/compilation/tst_compilation.cpp | 4 | ||||
-rw-r--r-- | tests/benchmarks/qml/creation/tst_creation.cpp | 89 |
3 files changed, 93 insertions, 2 deletions
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index c7e7c6829a..bd071ecf5c 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs SUBDIRS = qml script contains(QT_CONFIG, private_tests) { - SUBDIRS += particles + contains(QT_CONFIG, opengl(es1|es2)?):SUBDIRS += particles } diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp index 3f2cb5b94f..690e193b53 100644 --- a/tests/benchmarks/qml/compilation/tst_compilation.cpp +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -75,7 +75,9 @@ void tst_compilation::boomblock() QQmlComponent c(&engine); c.setData(data, QUrl()); } - +#ifdef QT_NO_OPENGL + QSKIP("boomblock imports Particles which requires OpenGL Support"); +#endif QBENCHMARK { QQmlComponent c(&engine); c.setData(data, QUrl()); diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index b47bc14a3e..ca5802a8e7 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -68,6 +68,12 @@ private slots: void itemtests_qml_data(); void itemtests_qml(); + void bindings_cpp(); + void bindings_cpp2(); + void bindings_qml(); + + void bindings_parent_qml(); + void anchors_creation(); void anchors_heightChange(); @@ -382,6 +388,89 @@ void tst_creation::itemtests_qml() QBENCHMARK { delete component.create(); } } +void tst_creation::bindings_cpp() +{ + QQuickItem item; + QMetaProperty widthProp = item.metaObject()->property(item.metaObject()->indexOfProperty("width")); + QMetaProperty heightProp = item.metaObject()->property(item.metaObject()->indexOfProperty("height")); + connect(&item, &QQuickItem::heightChanged, [&item, &widthProp, &heightProp](){ + QVariant height = heightProp.read(&item); + widthProp.write(&item, height); + }); + + int height = 0; + QBENCHMARK { + item.setHeight(++height); + } +} + +void tst_creation::bindings_cpp2() +{ + QQuickItem item; + int widthProp = item.metaObject()->indexOfProperty("width"); + int heightProp = item.metaObject()->indexOfProperty("height"); + connect(&item, &QQuickItem::heightChanged, [&item, widthProp, heightProp](){ + + qreal height = -1; + void *args[] = { &height, 0 }; + QMetaObject::metacall(&item, QMetaObject::ReadProperty, heightProp, args); + + int flags = 0; + int status = -1; + void *argv[] = { &height, 0, &status, &flags }; + QMetaObject::metacall(&item, QMetaObject::WriteProperty, widthProp, argv); + }); + + int height = 0; + QBENCHMARK { + item.setHeight(++height); + } +} + +void tst_creation::bindings_qml() +{ + QByteArray data = "import QtQuick 2.0\nItem { width: height }"; + + QQmlComponent component(&engine); + component.setData(data, QUrl()); + if (!component.isReady()) { + qWarning() << "Unable to create component: " << component.errorString(); + return; + } + + QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QVERIFY(obj != nullptr); + + int height = 0; + QBENCHMARK { + obj->setHeight(++height); + } + + delete obj; +} + +void tst_creation::bindings_parent_qml() +{ + QByteArray data = "import QtQuick 2.0\nItem { Item { width: parent.height }}"; + + QQmlComponent component(&engine); + component.setData(data, QUrl()); + if (!component.isReady()) { + qWarning() << "Unable to create component: " << component.errorString(); + return; + } + + QQuickItem *obj = dynamic_cast<QQuickItem *>(component.create()); + QVERIFY(obj != nullptr); + + int height = 0; + QBENCHMARK { + obj->setHeight(++height); + } + + delete obj; +} + void tst_creation::anchors_creation() { QQmlComponent component(&engine); |