summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/declarative/script/tst_script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/declarative/script/tst_script.cpp')
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp75
1 files changed, 74 insertions, 1 deletions
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
index 99f294c..5a7e151 100644
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ b/tests/benchmarks/declarative/script/tst_script.cpp
@@ -92,7 +92,12 @@ private slots:
void block_data();
void block();
-private:
+
+ void global_property_js();
+ void global_property_qml();
+ void global_property_qml_js();
+
+ void scriptfile_property();
};
inline QUrl TEST_FILE(const QString &filename)
@@ -625,6 +630,74 @@ void tst_script::block()
delete rect;
}
+#define GLOBALPROPERTY_PROGRAM \
+ "(function() { " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " Math.sin(90); " \
+ " } " \
+ "})"
+
+void tst_script::global_property_js()
+{
+ QScriptEngine engine;
+
+ QScriptValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::global_property_qml()
+{
+ QDeclarativeEngine qmlengine;
+
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine);
+ QScriptValue prog = engine->evaluate(GLOBALPROPERTY_PROGRAM);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::global_property_qml_js()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle *>(component.create());
+ QVERIFY(rect != 0);
+
+ int index = rect->metaObject()->indexOfMethod("triggered()");
+ QVERIFY(index != -1);
+ QMetaMethod method = rect->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(rect, Qt::DirectConnection);
+ }
+
+ delete rect;
+}
+
+void tst_script::scriptfile_property()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle *>(component.create());
+ QVERIFY(rect != 0);
+
+ int index = rect->metaObject()->indexOfMethod("incrementTriggered()");
+ QVERIFY(index != -1);
+ QMetaMethod method = rect->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(rect, Qt::DirectConnection);
+ }
+
+ delete rect;
+}
+
QTEST_MAIN(tst_script)
#include "tst_script.moc"