From fab7cd962bc108a0f1f38ba0276aeae4f7f0399d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 17 Mar 2010 15:51:35 +1000 Subject: Cleanup benchmark a little --- .../declarative/creation/tst_creation.cpp | 328 ++++++--------------- 1 file 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 resources READ resources); +Q_CLASSINFO("DefaultProperty", "resources"); +public: + TestType(QObject *parent = 0) + : QObject(parent) {} + + QDeclarativeListProperty resources() { + return QDeclarativeListProperty(this, 0, resources_append); + } + + static void resources_append(QDeclarativeListProperty *p, QObject *o) { + o->setParent(p->object); + } +}; + +tst_creation::tst_creation() +{ + qmlRegisterType("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("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(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" -- cgit v0.12 From 0a52765f1c7fbd7d5286bcaab32cff35feb89a95 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 17 Mar 2010 15:59:46 +1000 Subject: Compile --- tests/benchmarks/declarative/binding/testtypes.cpp | 2 +- tests/benchmarks/declarative/declarative.pro | 3 ++- tests/benchmarks/declarative/painting/paintbenchmark.pro | 13 ------------- tests/benchmarks/declarative/painting/painting.pro | 13 +++++++++++++ .../declarative/qdeclarativecomponent/testtypes.cpp | 2 +- .../declarative/qdeclarativetime/qdeclarativetime.cpp | 2 +- tests/benchmarks/declarative/script/tst_script.cpp | 2 +- 7 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 tests/benchmarks/declarative/painting/paintbenchmark.pro create mode 100644 tests/benchmarks/declarative/painting/painting.pro diff --git a/tests/benchmarks/declarative/binding/testtypes.cpp b/tests/benchmarks/declarative/binding/testtypes.cpp index 043c8ab..1fc9ccd 100644 --- a/tests/benchmarks/declarative/binding/testtypes.cpp +++ b/tests/benchmarks/declarative/binding/testtypes.cpp @@ -42,5 +42,5 @@ void registerTypes() { - QML_REGISTER_TYPE(Test, 1, 0, MyQmlObject, MyQmlObject); + qmlRegisterType("Test", 1, 0, "MyQmlObject"); } diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index 8c0ed42..38ea6c4 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -2,9 +2,10 @@ TEMPLATE = subdirs SUBDIRS += \ binding \ creation \ + painting \ pointers \ qdeclarativecomponent \ qdeclarativeimage \ qdeclarativemetaproperty \ script \ -# qdeclarativetime + qdeclarativetime diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.pro b/tests/benchmarks/declarative/painting/paintbenchmark.pro deleted file mode 100644 index 2f98e8b..0000000 --- a/tests/benchmarks/declarative/painting/paintbenchmark.pro +++ /dev/null @@ -1,13 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) fr 29. jan 13:57:52 2010 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += paintbenchmark.cpp -QT += opengl -CONFIG += console diff --git a/tests/benchmarks/declarative/painting/painting.pro b/tests/benchmarks/declarative/painting/painting.pro new file mode 100644 index 0000000..2f98e8b --- /dev/null +++ b/tests/benchmarks/declarative/painting/painting.pro @@ -0,0 +1,13 @@ +###################################################################### +# Automatically generated by qmake (2.01a) fr 29. jan 13:57:52 2010 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += paintbenchmark.cpp +QT += opengl +CONFIG += console diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp index acdc395..7bc6ca2 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp +++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp @@ -42,5 +42,5 @@ void registerTypes() { - QML_REGISTER_TYPE(Qt.test, 4, 6, MyQmlObject, MyQmlObject); + qmlRegisterType("Qt.test", 4, 6, "MyQmlObject"); } diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp index a924337..20f0d93d 100644 --- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp +++ b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp @@ -156,7 +156,7 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); - QML_REGISTER_TYPE(QDeclarativeTime, 1, 0, Timer, Timer); + qmlRegisterType("QDeclarativeTime", 1, 0, "Timer"); uint iterations = 1024; QString filename; diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index 9dd4076..8ea6dcd 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -144,7 +144,7 @@ int TestObject::x() void tst_script::initTestCase() { - QML_REGISTER_TYPE(Qt.test, 1, 0, TestObject, TestObject); + qmlRegisterType("Qt.test", 1, 0, "TestObject"); } -- cgit v0.12 From 1c4bb7a951ae50983a38acaf633eab272d3603b9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 17 Mar 2010 16:26:20 +1000 Subject: Allow enum constants as list element properties. Task-number: QTBUG-5974 --- src/declarative/qml/qdeclarativecompiler.cpp | 23 ++++++++++++++++++++++ src/declarative/qml/qdeclarativecompiler_p.h | 2 ++ src/declarative/qml/qdeclarativecustomparser.cpp | 12 +++++++++++ src/declarative/qml/qdeclarativecustomparser_p.h | 7 +++++++ src/declarative/util/qdeclarativelistmodel.cpp | 20 +++++++++++++++---- .../tst_qdeclarativelistmodel.cpp | 5 +++-- 6 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 06ff47c..5dc3858 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -825,7 +825,9 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt) if (isCustomParser && !customProps.isEmpty()) { QDeclarativeCustomParser *cp = output->types.at(obj->type).type->customParser(); cp->clearErrors(); + cp->compiler = this; obj->custom = cp->compile(customProps); + cp->compiler = 0; foreach (QDeclarativeError err, cp->errors()) { err.setUrl(output->url); exceptions << err; @@ -2184,6 +2186,27 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop return true; } +// Similar logic to above, but not knowing target property. +int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const +{ + int dot = script.find('.'); + if (dot > 0) { + QDeclarativeType *type = 0; + QDeclarativeEnginePrivate::get(engine)->resolveType(unit->imports, script.left(dot), &type, 0, 0, 0, 0); + if (!type) + return -1; + const QMetaObject *mo = type->metaObject(); + const char *key = script.constData() + dot+1; + int i = mo->enumeratorCount(); + while (i--) { + int v = mo->enumerator(i).keyToValue(key); + if (v >= 0) + return v; + } + } + return -1; +} + // Ensures that the dynamic meta specification on obj is valid bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) { diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 05b556e..a81259b 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -161,6 +161,8 @@ public: static QMetaMethod findSignalByName(const QMetaObject *, const QByteArray &name); + int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum + private: static void reset(QDeclarativeCompiledData *); diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp index 67f0963..a3a511c 100644 --- a/src/declarative/qml/qdeclarativecustomparser.cpp +++ b/src/declarative/qml/qdeclarativecustomparser.cpp @@ -43,6 +43,7 @@ #include "qdeclarativecustomparser_p_p.h" #include "qdeclarativeparser_p.h" +#include "qdeclarativecompiler_p.h" #include @@ -260,4 +261,15 @@ void QDeclarativeCustomParser::error(const QDeclarativeCustomParserNode& node, c exceptions << error; } +/*! + If \a script is a simply enum expression (eg. Text.AlignLeft), + returns the integer equivalent (eg. 1). + + Otherwise, returns -1. +*/ +int QDeclarativeCustomParser::evaluateEnum(const QByteArray& script) const +{ + return compiler->evaluateEnum(script); +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h index 39bd43c..f9bf513 100644 --- a/src/declarative/qml/qdeclarativecustomparser_p.h +++ b/src/declarative/qml/qdeclarativecustomparser_p.h @@ -66,6 +66,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +class QDeclarativeCompiler; + class QDeclarativeCustomParserPropertyPrivate; class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserProperty { @@ -111,6 +113,7 @@ private: class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser { public: + QDeclarativeCustomParser() : compiler(0) {} virtual ~QDeclarativeCustomParser() {} void clearErrors(); @@ -124,8 +127,12 @@ protected: void error(const QDeclarativeCustomParserProperty&, const QString& description); void error(const QDeclarativeCustomParserNode&, const QString& description); + int evaluateEnum(const QByteArray&) const; + private: QList exceptions; + QDeclarativeCompiler *compiler; + friend class QDeclarativeCompiler; }; #if 0 diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 824e1b5..32a996d 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -94,9 +94,12 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM } \endcode - Roles (properties) must begin with a lower-case letter. The above example defines a + Roles (properties) must begin with a lower-case letter.The above example defines a ListModel containing three elements, with the roles "name" and "cost". + Values must be simple constants - either strings (quoted), bools (true, false), numbers, + or enum values (like Text.AlignHCenter). + The defined model can be used in views such as ListView: \code Component { @@ -167,6 +170,8 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM } \endcode + \section2 Modifying list models + The content of a ListModel may be created and modified using the clear(), append(), and set() methods. For example: @@ -674,10 +679,17 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser d += char(variant.asBoolean()); } else if (variant.isScript()) { if (definesEmptyList(variant.asScript())) { - d[0] = 0; // QDeclarativeParser::Variant::Invalid - marks empty list + d[0] = char(QDeclarativeParser::Variant::Invalid); // marks empty list } else { - error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value")); - return false; + QByteArray script = variant.asScript().toUtf8(); + int v = evaluateEnum(script); + if (v<0) { + error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value")); + return false; + } else { + d[0] = char(QDeclarativeParser::Variant::Number); + d += QByteArray::number(v); + } } } d.append('\0'); diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 78e5912..576fe21 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include #include +#include #include #include #include @@ -459,7 +460,7 @@ void tst_QDeclarativeListModel::static_types_data() QTest::newRow("enum") << "ListElement { foo: Text.AlignHCenter }" - << QVariant("QTBUG-5974:ListElement: constant script support for property value"); + << QVariant(double(QDeclarativeText::AlignHCenter)); } void tst_QDeclarativeListModel::static_types() @@ -516,7 +517,7 @@ void tst_QDeclarativeListModel::error_data() QTest::newRow("bindings not allowed in ListElement") << "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" - << "ListElement: cannot use script for property value"; // but note QTBUG-5974 + << "ListElement: cannot use script for property value"; QTest::newRow("random object list properties allowed in ListElement") << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" -- cgit v0.12 From caea4098b275eaecdf0c5c4019b897e47d8d9c13 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 17 Mar 2010 16:49:13 +1000 Subject: Readd the itemtree benchmarks for comparison purposes. --- .../declarative/creation/tst_creation.cpp | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) 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(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("type"); -- cgit v0.12