summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-17 05:51:35 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-17 05:52:29 (GMT)
commitfab7cd962bc108a0f1f38ba0276aeae4f7f0399d (patch)
treeee0d24f944c2c5f44acd905684a7cb465034487a /tests/benchmarks/declarative
parent2fc57473958c566b25be0f8715e72fa3e4811717 (diff)
downloadQt-fab7cd962bc108a0f1f38ba0276aeae4f7f0399d.zip
Qt-fab7cd962bc108a0f1f38ba0276aeae4f7f0399d.tar.gz
Qt-fab7cd962bc108a0f1f38ba0276aeae4f7f0399d.tar.bz2
Cleanup benchmark a little
Diffstat (limited to 'tests/benchmarks/declarative')
-rw-r--r--tests/benchmarks/declarative/creation/tst_creation.cpp328
1 files changed, 96 insertions, 232 deletions
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp
index cd69cfe..743caa4 100644
--- a/tests/benchmarks/declarative/creation/tst_creation.cpp
+++ b/tests/benchmarks/declarative/creation/tst_creation.cpp
@@ -60,7 +60,7 @@ class tst_creation : public QObject
{
Q_OBJECT
public:
- tst_creation() {}
+ tst_creation();
private slots:
void qobject_cpp();
@@ -68,27 +68,42 @@ private slots:
void qobject_qmltype();
void qobject_alloc();
- void qdeclarativecontext();
+ void qobject_10flat_qml();
+ void qobject_10flat_cpp();
- void objects_qmltype_data();
- void objects_qmltype();
+ void qobject_10tree_qml();
+ void qobject_10tree_cpp();
- void qgraphicsitem();
- void qgraphicsobject();
- void qgraphicsitem14();
- void qgraphicsitem_tree14();
-
- 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();
private:
QDeclarativeEngine engine;
};
+class TestType : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources);
+Q_CLASSINFO("DefaultProperty", "resources");
+public:
+ TestType(QObject *parent = 0)
+ : QObject(parent) {}
+
+ QDeclarativeListProperty<QObject> resources() {
+ return QDeclarativeListProperty<QObject>(this, 0, resources_append);
+ }
+
+ static void resources_append(QDeclarativeListProperty<QObject> *p, QObject *o) {
+ o->setParent(p->object);
+ }
+};
+
+tst_creation::tst_creation()
+{
+ qmlRegisterType<TestType>("Qt.test", 1, 0, "TestType");
+}
+
inline QUrl TEST_FILE(const QString &filename)
{
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
@@ -115,6 +130,70 @@ void tst_creation::qobject_qml()
}
}
+void tst_creation::qobject_10flat_qml()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt.test 1.0\nTestType { resources: [ TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{} ] }", QUrl());
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_creation::qobject_10flat_cpp()
+{
+ QBENCHMARK {
+ QObject *item = new TestType;
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ delete item;
+ }
+}
+
+void tst_creation::qobject_10tree_qml()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt.test 1.0\nTestType { TestType{ TestType { TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ } } } } } } } } } } }", QUrl());
+
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_creation::qobject_10tree_cpp()
+{
+ QBENCHMARK {
+ QObject *item = new TestType;
+ QObject *root = item;
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ delete root;
+ }
+}
+
void tst_creation::qobject_qmltype()
{
QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6);
@@ -154,15 +233,7 @@ void tst_creation::qobject_alloc()
}
}
-void tst_creation::qdeclarativecontext()
-{
- QBENCHMARK {
- QDeclarativeContext *ctxt = new QDeclarativeContext(&engine);
- delete ctxt;
- }
-}
-
-void tst_creation::objects_qmltype_data()
+void tst_creation::elements_data()
{
QTest::addColumn<QByteArray>("type");
@@ -171,7 +242,7 @@ void tst_creation::objects_qmltype_data()
QTest::newRow(type.constData()) << type;
}
-void tst_creation::objects_qmltype()
+void tst_creation::elements()
{
QFETCH(QByteArray, type);
QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6);
@@ -184,213 +255,6 @@ void tst_creation::objects_qmltype()
}
}
-class QGraphicsItemDummy : public QGraphicsItem
-{
-public:
- virtual QRectF boundingRect() const { return QRectF(); }
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
-};
-
-class QGraphicsObjectDummy : public QGraphicsObject
-{
-public:
- virtual QRectF boundingRect() const { return QRectF(); }
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
-};
-
-void tst_creation::qgraphicsitem()
-{
- QBENCHMARK {
- QGraphicsItemDummy *i = new QGraphicsItemDummy();
- delete i;
- }
-}
-
-void tst_creation::qgraphicsobject()
-{
- QBENCHMARK {
- QGraphicsObjectDummy *i = new QGraphicsObjectDummy();
- delete i;
- }
-}
-
-void tst_creation::qgraphicsitem14()
-{
- QBENCHMARK {
- QGraphicsItemDummy *i1 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i2 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i3 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i4 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i5 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i6 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i7 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i8 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i9 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i10 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i11 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i12 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i13 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i14 = new QGraphicsItemDummy();
-
- delete i1;
- delete i2;
- delete i3;
- delete i4;
- delete i5;
- delete i6;
- delete i7;
- delete i8;
- delete i9;
- delete i10;
- delete i11;
- delete i12;
- delete i13;
- delete i14;
- }
-}
-
-void tst_creation::qgraphicsitem_tree14()
-{
- QBENCHMARK {
- // i1
- // +-------------------------+
- // i2 i3
- // +-----------+ +-----+-----+
- // i4 i5 i6 i7
- // +----+ +--+ +--+--+ +----+
- // i8 i9 i10 i11 i12 i13 i14
-
- QGraphicsItemDummy *i1 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i2 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i3 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i4 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i5 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i6 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i7 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i8 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i9 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i10 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i11 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i12 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i13 = new QGraphicsItemDummy();
- QGraphicsItemDummy *i14 = new QGraphicsItemDummy();
-
- i14->setParentItem(i7);
- i13->setParentItem(i7);
- i12->setParentItem(i6);
- i11->setParentItem(i6);
- i10->setParentItem(i5);
- i9->setParentItem(i4);
- i8->setParentItem(i4);
-
- i7->setParentItem(i3);
- i6->setParentItem(i3);
- i5->setParentItem(i2);
- i4->setParentItem(i2);
-
- i3->setParentItem(i1);
- i2->setParentItem(i1);
-
- delete i1;
- }
-}
-
-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;
-}
-
-
QTEST_MAIN(tst_creation)
#include "tst_creation.moc"