diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-12-09 03:03:32 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-12-09 03:03:32 (GMT) |
commit | 0150b8ffd4e12ca0f3c5197ce225d81b0f9d1537 (patch) | |
tree | a05b2cadff70ecc690fa3b7aa2e8462aa95347bf /tests | |
parent | abef2069a4f1afbbf373ec0b667838dadd926798 (diff) | |
download | Qt-0150b8ffd4e12ca0f3c5197ce225d81b0f9d1537.zip Qt-0150b8ffd4e12ca0f3c5197ce225d81b0f9d1537.tar.gz Qt-0150b8ffd4e12ca0f3c5197ce225d81b0f9d1537.tar.bz2 |
Item creation benchmarks.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/benchmarks/declarative/creation/tst_creation.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 99411d4..a73de41 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -45,6 +45,7 @@ #include <QmlMetaType> #include <QDebug> #include <QGraphicsItem> +#include <QmlGraphicsItem> #include <private/qobject_p.h> class tst_creation : public QObject @@ -65,6 +66,12 @@ private slots: void qgraphicsitem(); void qgraphicsitem_tree(); + void itemtree_notree_cpp(); + void itemtree_objtree_cpp(); + void itemtree_cpp(); + void itemtree_data_cpp(); + void itemtree_qml(); + private: QmlEngine engine; }; @@ -241,6 +248,82 @@ void tst_creation::qgraphicsitem_tree() } } +struct QmlGraphics_DerivedObject : public QObject +{ + void setParent_noEvent(QObject *parent) { + bool sce = d_ptr->sendChildEvents; + d_ptr->sendChildEvents = false; + setParent(parent); + d_ptr->sendChildEvents = sce; + } +}; + +inline void QmlGraphics_setParent_noEvent(QObject *object, QObject *parent) +{ + static_cast<QmlGraphics_DerivedObject *>(object)->setParent_noEvent(parent); +} + +void tst_creation::itemtree_notree_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + } + delete item; + } +} + +void tst_creation::itemtree_objtree_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + QmlGraphics_setParent_noEvent(child,item); + } + delete item; + } +} + +void tst_creation::itemtree_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + QmlGraphics_setParent_noEvent(child,item); + child->setParentItem(item); + } + delete item; + } +} + +void tst_creation::itemtree_data_cpp() +{ + QBENCHMARK { + QmlGraphicsItem *item = new QmlGraphicsItem; + for (int i = 0; i < 30; ++i) { + QmlGraphicsItem *child = new QmlGraphicsItem; + QmlGraphics_setParent_noEvent(child,item); + item->data()->append(child); + } + delete item; + } +} + +void tst_creation::itemtree_qml() +{ + QmlComponent component(&engine, TEST_FILE("item.qml")); + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + QTEST_MAIN(tst_creation) |