Skip to content

Commit

Permalink
Benchmark component creation with different types of bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Jones committed May 10, 2011
1 parent 4fb6ee7 commit e7f900b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/benchmarks/declarative/binding/data/creation.txt
@@ -0,0 +1,9 @@
import Test 1.0

MyQmlObject {
id: myObject
property int myValue: 1
object: myObject

result: ###
}
Expand Up @@ -2,6 +2,7 @@ import Test 1.0

MyQmlObject {
id: myObject
object: myObject

result: ###
}
28 changes: 28 additions & 0 deletions tests/benchmarks/declarative/binding/tst_binding.cpp
Expand Up @@ -41,6 +41,7 @@

#include <qtest.h>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <QDeclarativeComponent>
#include <QFile>
#include <QDebug>
Expand Down Expand Up @@ -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()
Expand All @@ -86,6 +90,7 @@ tst_binding::~tst_binding()
void tst_binding::initTestCase()
{
registerTypes();
engine.rootContext()->setContextProperty("tstObject", &tstObject);
}

void tst_binding::cleanupTestCase()
Expand Down Expand Up @@ -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"

0 comments on commit e7f900b

Please sign in to comment.