summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-01-08 05:14:44 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-01-08 05:14:44 (GMT)
commit7cd2c43e41e204f5662a51c72b31e0606b71def3 (patch)
tree7405e9245dc66d3da2497f1afc5e500c440cee01
parent7abc7b839223eaf05006fe35dceec690fee5ce3d (diff)
downloadQt-7cd2c43e41e204f5662a51c72b31e0606b71def3.zip
Qt-7cd2c43e41e204f5662a51c72b31e0606b71def3.tar.gz
Qt-7cd2c43e41e204f5662a51c72b31e0606b71def3.tar.bz2
QML dynamic function benchmark
-rw-r--r--tests/benchmarks/declarative/script/data/slot_complex.qml16
-rw-r--r--tests/benchmarks/declarative/script/data/slot_complex_js.qml18
-rw-r--r--tests/benchmarks/declarative/script/data/slot_simple.qml9
-rw-r--r--tests/benchmarks/declarative/script/data/slot_simple_js.qml13
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp61
5 files changed, 117 insertions, 0 deletions
diff --git a/tests/benchmarks/declarative/script/data/slot_complex.qml b/tests/benchmarks/declarative/script/data/slot_complex.qml
new file mode 100644
index 0000000..d71120d
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/slot_complex.qml
@@ -0,0 +1,16 @@
+import Qt.test 1.0
+
+TestObject {
+ function myCustomFunction(b) {
+ var n = b;
+ var a = 1;
+ while (n > 0) {
+ a = a * n;
+ n--;
+ }
+ return a;
+ }
+
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } }
+}
+
diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.qml b/tests/benchmarks/declarative/script/data/slot_complex_js.qml
new file mode 100644
index 0000000..ed4f78b
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/slot_complex_js.qml
@@ -0,0 +1,18 @@
+import Qt.test 1.0
+
+TestObject {
+ Script {
+ function myCustomFunction(n) {
+ var a = 1;
+ while (n > 0) {
+ a = a * n;
+ n--;
+ }
+ return a;
+ }
+ }
+
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } }
+}
+
+
diff --git a/tests/benchmarks/declarative/script/data/slot_simple.qml b/tests/benchmarks/declarative/script/data/slot_simple.qml
new file mode 100644
index 0000000..4ba98d7
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/slot_simple.qml
@@ -0,0 +1,9 @@
+import Qt.test 1.0
+
+TestObject {
+ function myCustomFunction() {
+ return 0;
+ }
+
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } }
+}
diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.qml b/tests/benchmarks/declarative/script/data/slot_simple_js.qml
new file mode 100644
index 0000000..a88265c
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/slot_simple_js.qml
@@ -0,0 +1,13 @@
+import Qt.test 1.0
+
+TestObject {
+
+ Script {
+ function myCustomFunction() {
+ return 0;
+ }
+ }
+
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } }
+}
+
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
index 9da795d..3c0805a 100644
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ b/tests/benchmarks/declarative/script/tst_script.cpp
@@ -76,6 +76,11 @@ private slots:
void signal_qml();
void signal_args();
void signal_unusedArgs();
+
+ void slot_simple();
+ void slot_simple_js();
+ void slot_complex();
+ void slot_complex_js();
private:
};
@@ -521,6 +526,62 @@ void tst_script::signal_unusedArgs()
delete object;
}
+void tst_script::slot_simple()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("slot_simple.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::slot_simple_js()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("slot_simple_js.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::slot_complex()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("slot_complex.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::slot_complex_js()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("slot_complex_js.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
QTEST_MAIN(tst_script)
#include "tst_script.moc"