diff options
17 files changed, 358 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index 40ffffe..3fe24ea 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -443,6 +443,18 @@ void QmlBasicScript::dump() qWarning().nospace() << "FETCH\t\t" << instr.fetch.idx << "\t\t" << QByteArray(data + instr.fetch.idx); break; + case ScriptInstruction::LoadIdObject: + qWarning().nospace() << "LOAD_ID_OBJECT"; + break; + case ScriptInstruction::FetchConstant: + qWarning().nospace() << "FETCH_CONSTANT"; + break; + case ScriptInstruction::FetchD0Constant: + qWarning().nospace() << "FETCH_D0_CONSTANT"; + break; + case ScriptInstruction::FetchD1Constant: + qWarning().nospace() << "FETCH_D1_CONSTANT"; + break; case ScriptInstruction::Equals: qWarning().nospace() << "EQUALS"; break; diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro new file mode 100644 index 0000000..26ee4fa --- /dev/null +++ b/tests/benchmarks/declarative/binding/binding.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_binding +QT += declarative + +SOURCES += tst_binding.cpp testtypes.cpp +HEADERS += testtypes.h + diff --git a/tests/benchmarks/declarative/binding/idproperty.txt b/tests/benchmarks/declarative/binding/idproperty.txt new file mode 100644 index 0000000..0a98e0d --- /dev/null +++ b/tests/benchmarks/declarative/binding/idproperty.txt @@ -0,0 +1,7 @@ +MyQmlObject { + id: MyObject + + MyQmlObject { + result: ### + } +} diff --git a/tests/benchmarks/declarative/binding/localproperty.txt b/tests/benchmarks/declarative/binding/localproperty.txt new file mode 100644 index 0000000..4694d99 --- /dev/null +++ b/tests/benchmarks/declarative/binding/localproperty.txt @@ -0,0 +1,3 @@ +MyQmlObject { + result: ### +} diff --git a/tests/benchmarks/declarative/binding/objectproperty.txt b/tests/benchmarks/declarative/binding/objectproperty.txt new file mode 100644 index 0000000..597c965 --- /dev/null +++ b/tests/benchmarks/declarative/binding/objectproperty.txt @@ -0,0 +1,5 @@ +MyQmlObject { + id: MyObject + + result: ### +} diff --git a/tests/benchmarks/declarative/binding/testtypes.cpp b/tests/benchmarks/declarative/binding/testtypes.cpp new file mode 100644 index 0000000..60e69e2 --- /dev/null +++ b/tests/benchmarks/declarative/binding/testtypes.cpp @@ -0,0 +1,3 @@ +#include "testtypes.h" + +QML_DEFINE_TYPE(MyQmlObject, MyQmlObject); diff --git a/tests/benchmarks/declarative/binding/testtypes.h b/tests/benchmarks/declarative/binding/testtypes.h new file mode 100644 index 0000000..20bf5f7 --- /dev/null +++ b/tests/benchmarks/declarative/binding/testtypes.h @@ -0,0 +1,41 @@ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include <QtCore/qobject.h> +#include <QtDeclarative/qml.h> + +class MyQmlObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int result READ result WRITE setResult); + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); + Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged); + Q_PROPERTY(QmlList<QObject *> *data READ data); + Q_CLASSINFO("DefaultProperty", "data"); +public: + MyQmlObject() : m_result(0), m_value(0), m_object(0) {} + + int result() const { return m_result; } + void setResult(int r) { m_result = r; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; emit valueChanged(); } + + QmlList<QObject *> *data() { return &m_data; } + + MyQmlObject *object() const { return m_object; } + void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } + +signals: + void valueChanged(); + void objectChanged(); + +private: + QmlConcreteList<QObject *> m_data; + int m_result; + int m_value; + MyQmlObject *m_object; +}; +QML_DECLARE_TYPE(MyQmlObject); + +#endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp new file mode 100644 index 0000000..e593382 --- /dev/null +++ b/tests/benchmarks/declarative/binding/tst_binding.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +****************************************************************************/ + +#include <qtest.h> +#include <QmlEngine> +#include <QmlComponent> +#include <QFile> +#include <QDebug> +#include "testtypes.h" + +//TESTED_FILES= + +class tst_binding : public QObject +{ + Q_OBJECT + +public: + tst_binding(); + virtual ~tst_binding(); + +public slots: + void init(); + void cleanup(); + +private slots: + void objectproperty_data(); + void objectproperty(); + void basicproperty_data(); + void basicproperty(); + +private: + QmlEngine engine; +}; + +tst_binding::tst_binding() +{ +} + +tst_binding::~tst_binding() +{ +} + +void tst_binding::init() +{ +} + +void tst_binding::cleanup() +{ +} + +#define COMPONENT(filename, binding) \ + QmlComponent c(&engine); \ + { \ + QFile f(filename); \ + QVERIFY(f.open(QIODevice::ReadOnly)); \ + QByteArray data = f.readAll(); \ + data.replace("###", binding.toUtf8()); \ + c.setData(data, QUrl()); \ + QVERIFY(c.isReady()); \ + } + +void tst_binding::objectproperty_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("binding"); + + QTest::newRow("object.value") << "objectproperty.txt" << "object.value"; + QTest::newRow("object.value + 10") << "objectproperty.txt" << "object.value + 10"; +} + +void tst_binding::objectproperty() +{ + QFETCH(QString, file); + QFETCH(QString, binding); + + COMPONENT(file, binding); + + MyQmlObject object1; + MyQmlObject object2; + + MyQmlObject *object = qobject_cast<MyQmlObject *>(c.create()); + QVERIFY(object != 0); + object->setObject(&object2); + + QBENCHMARK { + object->setObject(&object1); + object->setObject(&object2); + } +} + +void tst_binding::basicproperty_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("binding"); + + QTest::newRow("value") << "localproperty.txt" << "value"; + QTest::newRow("value + 10") << "localproperty.txt" << "value + 10"; + QTest::newRow("value + value + 10") << "localproperty.txt" << "value + value + 10"; + + QTest::newRow("MyObject.value") << "idproperty.txt" << "MyObject.value"; + QTest::newRow("MyObject.value + 10") << "idproperty.txt" << "MyObject.value + 10"; + QTest::newRow("MyObject.value + MyObject.value + 10") << "idproperty.txt" << "MyObject.value + MyObject.value + 10"; +} + +void tst_binding::basicproperty() +{ + QFETCH(QString, file); + QFETCH(QString, binding); + + COMPONENT(file, binding); + + MyQmlObject *object = qobject_cast<MyQmlObject *>(c.create()); + QVERIFY(object != 0); + object->setValue(10); + + QBENCHMARK { + object->setValue(1); + } +} + +QTEST_MAIN(tst_binding) +#include "tst_binding.moc" diff --git a/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt b/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt new file mode 100644 index 0000000..05ed87a --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt @@ -0,0 +1 @@ +MyQmlObject {} diff --git a/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt b/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt new file mode 100644 index 0000000..4dfa7c3 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt @@ -0,0 +1,4 @@ +MyQmlObject { + result: value +} + diff --git a/tests/benchmarks/declarative/qmlcomponent/object.txt b/tests/benchmarks/declarative/qmlcomponent/object.txt new file mode 100644 index 0000000..7dc75192 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/object.txt @@ -0,0 +1 @@ +Object {} diff --git a/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro b/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro new file mode 100644 index 0000000..5f0cbe6 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qmlcomponent +QT += declarative + +SOURCES += tst_qmlcomponent.cpp testtypes.cpp +HEADERS += testtypes.h + diff --git a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt new file mode 100644 index 0000000..d59104d --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt @@ -0,0 +1,13 @@ +Object { + property int a + property bool b + property double c + property real d + property string e + property url f + property color g + property date h + property var i + property variant j +} + diff --git a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt new file mode 100644 index 0000000..d9eb708 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt @@ -0,0 +1,3 @@ +Object { + property int a +} diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp new file mode 100644 index 0000000..60e69e2 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp @@ -0,0 +1,3 @@ +#include "testtypes.h" + +QML_DEFINE_TYPE(MyQmlObject, MyQmlObject); diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.h b/tests/benchmarks/declarative/qmlcomponent/testtypes.h new file mode 100644 index 0000000..20bf5f7 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/testtypes.h @@ -0,0 +1,41 @@ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include <QtCore/qobject.h> +#include <QtDeclarative/qml.h> + +class MyQmlObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int result READ result WRITE setResult); + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); + Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged); + Q_PROPERTY(QmlList<QObject *> *data READ data); + Q_CLASSINFO("DefaultProperty", "data"); +public: + MyQmlObject() : m_result(0), m_value(0), m_object(0) {} + + int result() const { return m_result; } + void setResult(int r) { m_result = r; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; emit valueChanged(); } + + QmlList<QObject *> *data() { return &m_data; } + + MyQmlObject *object() const { return m_object; } + void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } + +signals: + void valueChanged(); + void objectChanged(); + +private: + QmlConcreteList<QObject *> m_data; + int m_result; + int m_value; + MyQmlObject *m_object; +}; +QML_DECLARE_TYPE(MyQmlObject); + +#endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp new file mode 100644 index 0000000..1920bf2 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +****************************************************************************/ + +#include <qtest.h> +#include <QmlEngine> +#include <QmlComponent> +#include <QFile> +#include <QDebug> +#include "testtypes.h" + +//TESTED_FILES= + + +class tst_qmlcomponent : public QObject +{ + Q_OBJECT + +public: + tst_qmlcomponent(); + virtual ~tst_qmlcomponent(); + +public slots: + void init(); + void cleanup(); + +private slots: + void creation_data(); + void creation(); + +private: + QmlEngine engine; +}; + +tst_qmlcomponent::tst_qmlcomponent() +{ +} + +tst_qmlcomponent::~tst_qmlcomponent() +{ +} + +void tst_qmlcomponent::init() +{ +} + +void tst_qmlcomponent::cleanup() +{ +} + +void tst_qmlcomponent::creation_data() +{ + QTest::addColumn<QString>("file"); + + QTest::newRow("Object") << "object.txt"; + QTest::newRow("MyQmlObject") << "myqmlobject.txt"; + QTest::newRow("MyQmlObject: basic binding") << "myqmlobject_binding.txt"; + QTest::newRow("Synthesized properties") << "synthesized_properties.txt"; + QTest::newRow("Synthesized properties.2") << "synthesized_properties.2.txt"; +} + +void tst_qmlcomponent::creation() +{ + QFETCH(QString, file); + + QmlComponent c(&engine, file); + QVERIFY(c.isReady()); + + QBENCHMARK { + QObject *obj = c.create(); + delete obj; + } +} + +QTEST_MAIN(tst_qmlcomponent) +#include "tst_qmlcomponent.moc" |