summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-05-04 16:11:28 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-05-04 16:11:28 (GMT)
commitb59fb6e41ffe971c4f33a2595e10db2f8ecc9c15 (patch)
treefe7de2f1485338756e6cbb1837b0a5b519af179f /tests/benchmarks
parent049447d37d27c461c34d7ff52be2054ecd3208e3 (diff)
parentcc26af5ad405a76b59fc21a34862ce83744a0374 (diff)
downloadQt-b59fb6e41ffe971c4f33a2595e10db2f8ecc9c15.zip
Qt-b59fb6e41ffe971c4f33a2595e10db2f8ecc9c15.tar.gz
Qt-b59fb6e41ffe971c4f33a2595e10db2f8ecc9c15.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-qml-staging: QmlViewer: Translate UI Fix insert and scroll to bottom case QDeclarativeDebug: Fix test case QDeclarativeDebug: Handle case where client with ongoing queries is deleted Remove compile warning Fix QUnifiedTimer bug Stop the animation driver when there are no more animations. Optimization and benchmark for setting object properties from QML. Add Constant and Final flags to QMetaObjectBuilder Fixed QML TextEdit docs Make -no-opengl exist on other platforms Only ask for name when the user goes on the high score list.
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
index 2020a18..b07ffa1 100644
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ b/tests/benchmarks/declarative/script/tst_script.cpp
@@ -70,6 +70,9 @@ private slots:
void property_qobject();
void property_qmlobject();
+ void setproperty_js();
+ void setproperty_qmlobject();
+
void function_js();
void function_cpp();
void function_qobject();
@@ -108,12 +111,13 @@ inline QUrl TEST_FILE(const QString &filename)
class TestObject : public QObject
{
Q_OBJECT
- Q_PROPERTY(int x READ x)
+ Q_PROPERTY(int x READ x WRITE setX)
public:
TestObject(QObject *parent = 0);
int x();
+ void setX(int x) { m_x = x; }
void emitMySignal() { emit mySignal(); }
void emitMySignalWithArgs(int n) { emit mySignalWithArgs(n); }
@@ -323,6 +327,49 @@ void tst_script::property_qmlobject()
}
}
+#define SETPROPERTY_PROGRAM \
+ "(function(testObject) { return (function() { " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " testObject.x = ii; " \
+ " } " \
+ "}); })"
+
+void tst_script::setproperty_js()
+{
+ QScriptEngine engine;
+
+ QScriptValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), 0);
+
+ QScriptValueList args;
+ args << v;
+ QScriptValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(engine.globalObject(), args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::setproperty_qmlobject()
+{
+ QDeclarativeEngine qmlengine;
+
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine);
+ TestObject to;
+
+ QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
+
+ QScriptValueList args;
+ args << v;
+ QScriptValue prog = engine->evaluate(SETPROPERTY_PROGRAM).call(engine->globalObject(), args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
#define FUNCTION_PROGRAM \
"(function(testObject) { return (function() { " \
" var test = 0; " \