Benchmark component creation with different types of bindings.
authorMartin Jones <martin.jones@nokia.com>
Tue, 10 May 2011 04:46:10 +0000 (14:46 +1000)
committerMartin Jones <martin.jones@nokia.com>
Tue, 10 May 2011 05:33:46 +0000 (15:33 +1000)
tests/benchmarks/declarative/binding/data/creation.txt [new file with mode: 0644]
tests/benchmarks/declarative/binding/data/objectproperty.txt
tests/benchmarks/declarative/binding/tst_binding.cpp

diff --git a/tests/benchmarks/declarative/binding/data/creation.txt b/tests/benchmarks/declarative/binding/data/creation.txt
new file mode 100644 (file)
index 0000000..05704fa
--- /dev/null
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyQmlObject {
+    id: myObject
+    property int myValue: 1
+    object: myObject
+
+    result: ###
+}
index 6133dd6..06409f2 100644 (file)
@@ -2,6 +2,7 @@ import Test 1.0
 
 MyQmlObject {
     id: myObject
+    object: myObject
 
     result: ###
 }
index b130652..d9ab06a 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <qtest.h>
 #include <QDeclarativeEngine>
+#include <QDeclarativeContext>
 #include <QDeclarativeComponent>
 #include <QFile>
 #include <QDebug>
@@ -70,9 +71,12 @@ private slots:
     void objectproperty();
     void basicproperty_data();
     void basicproperty();
+    void creation_data();
+    void creation();
 
 private:
     QDeclarativeEngine engine;
+    MyQmlObject tstObject;
 };
 
 tst_binding::tst_binding()
@@ -86,6 +90,7 @@ tst_binding::~tst_binding()
 void tst_binding::initTestCase()
 {
     registerTypes();
+    engine.rootContext()->setContextProperty("tstObject", &tstObject);
 }
 
 void tst_binding::cleanupTestCase()
@@ -162,5 +167,28 @@ void tst_binding::basicproperty()
     }
 }
 
+void tst_binding::creation_data()
+{
+    QTest::addColumn<QString>("file");
+    QTest::addColumn<QString>("binding");
+
+    QTest::newRow("constant") << SRCDIR "/data/creation.txt" << "10";
+    QTest::newRow("ownProperty") << SRCDIR "/data/creation.txt" << "myObject.value";
+    QTest::newRow("declaredProperty") << SRCDIR "/data/creation.txt" << "myObject.myValue";
+    QTest::newRow("contextProperty") << SRCDIR "/data/creation.txt" << "tstObject.value";
+}
+
+void tst_binding::creation()
+{
+    QFETCH(QString, file);
+    QFETCH(QString, binding);
+
+    COMPONENT(file, binding);
+
+    QBENCHMARK {
+        c.create();
+    }
+}
+
 QTEST_MAIN(tst_binding)
 #include "tst_binding.moc"