diff options
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" |