summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/declarative
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2011-05-06 07:30:14 (GMT)
committeraavit <qt-info@nokia.com>2011-05-06 07:30:14 (GMT)
commitb81e1b76231dfe41de1857e87d4f6bf918c609a6 (patch)
treeab5d96bd1299f426547e4845040f165bfd876fad /tests/benchmarks/declarative
parent7ac511d8d906575dff1a02361e31251b244d3b3a (diff)
parent1d9a18142eb19d5dde93b7e5c63f9be0e4caf896 (diff)
downloadQt-b81e1b76231dfe41de1857e87d4f6bf918c609a6.zip
Qt-b81e1b76231dfe41de1857e87d4f6bf918c609a6.tar.gz
Qt-b81e1b76231dfe41de1857e87d4f6bf918c609a6.tar.bz2
Merge remote branch 'qt-mainline/4.8'
Diffstat (limited to 'tests/benchmarks/declarative')
-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; " \