diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-17 06:49:13 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-17 06:49:13 (GMT) |
commit | caea4098b275eaecdf0c5c4019b897e47d8d9c13 (patch) | |
tree | c12985d86bd484ad4fe82ce8d02be934967908c3 /tests/benchmarks/declarative/creation | |
parent | 0a52765f1c7fbd7d5286bcaab32cff35feb89a95 (diff) | |
download | Qt-caea4098b275eaecdf0c5c4019b897e47d8d9c13.zip Qt-caea4098b275eaecdf0c5c4019b897e47d8d9c13.tar.gz Qt-caea4098b275eaecdf0c5c4019b897e47d8d9c13.tar.bz2 |
Readd the itemtree benchmarks for comparison purposes.
Diffstat (limited to 'tests/benchmarks/declarative/creation')
-rw-r--r-- | tests/benchmarks/declarative/creation/tst_creation.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 743caa4..7aec32a 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -74,6 +74,13 @@ private slots: void qobject_10tree_qml(); void qobject_10tree_cpp(); + void itemtree_notree_cpp(); + void itemtree_objtree_cpp(); + void itemtree_cpp(); + void itemtree_data_cpp(); + void itemtree_qml(); + void itemtree_scene_cpp(); + void elements_data(); void elements(); @@ -233,6 +240,101 @@ void tst_creation::qobject_alloc() } } +struct QDeclarativeGraphics_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 QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent) +{ + static_cast<QDeclarativeGraphics_DerivedObject *>(object)->setParent_noEvent(parent); +} + +void tst_creation::itemtree_notree_cpp() +{ + QBENCHMARK { + QDeclarativeItem *item = new QDeclarativeItem; + for (int i = 0; i < 30; ++i) { + QDeclarativeItem *child = new QDeclarativeItem; + } + delete item; + } +} + +void tst_creation::itemtree_objtree_cpp() +{ + QBENCHMARK { + QDeclarativeItem *item = new QDeclarativeItem; + for (int i = 0; i < 30; ++i) { + QDeclarativeItem *child = new QDeclarativeItem; + QDeclarativeGraphics_setParent_noEvent(child,item); + } + delete item; + } +} + +void tst_creation::itemtree_cpp() +{ + QBENCHMARK { + QDeclarativeItem *item = new QDeclarativeItem; + for (int i = 0; i < 30; ++i) { + QDeclarativeItem *child = new QDeclarativeItem; + QDeclarativeGraphics_setParent_noEvent(child,item); + child->setParentItem(item); + } + delete item; + } +} + +void tst_creation::itemtree_data_cpp() +{ + QBENCHMARK { + QDeclarativeItem *item = new QDeclarativeItem; + for (int i = 0; i < 30; ++i) { + QDeclarativeItem *child = new QDeclarativeItem; + QDeclarativeGraphics_setParent_noEvent(child,item); + QDeclarativeListReference ref(item, "data"); + ref.append(child); + } + delete item; + } +} + +void tst_creation::itemtree_qml() +{ + QDeclarativeComponent component(&engine, TEST_FILE("item.qml")); + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_creation::itemtree_scene_cpp() +{ + QGraphicsScene scene; + QDeclarativeItem *root = new QDeclarativeItem; + scene.addItem(root); + QBENCHMARK { + QDeclarativeItem *item = new QDeclarativeItem; + for (int i = 0; i < 30; ++i) { + QDeclarativeItem *child = new QDeclarativeItem; + QDeclarativeGraphics_setParent_noEvent(child,item); + child->setParentItem(item); + } + item->setParentItem(root); + delete item; + } + delete root; +} + void tst_creation::elements_data() { QTest::addColumn<QByteArray>("type"); |