summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-06-24 04:28:18 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-06-24 04:30:00 (GMT)
commit2bae9da77fbc6407ddb24d0fe8135698092cbb6a (patch)
tree65fed9de63fbf5ead6e7cf20c504f6e6975fdd58 /tests/benchmarks
parent736067120b466248cbfc3180a533dc416953c5e0 (diff)
downloadQt-2bae9da77fbc6407ddb24d0fe8135698092cbb6a.zip
Qt-2bae9da77fbc6407ddb24d0fe8135698092cbb6a.tar.gz
Qt-2bae9da77fbc6407ddb24d0fe8135698092cbb6a.tar.bz2
More script benchmarking.
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/declarative/script/data/global.js9
-rw-r--r--tests/benchmarks/declarative/script/data/global_prop.qml7
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp19
3 files changed, 31 insertions, 4 deletions
diff --git a/tests/benchmarks/declarative/script/data/global.js b/tests/benchmarks/declarative/script/data/global.js
index 02472d2..5b86b4d 100644
--- a/tests/benchmarks/declarative/script/data/global.js
+++ b/tests/benchmarks/declarative/script/data/global.js
@@ -39,7 +39,16 @@
**
****************************************************************************/
+var incVar = 1;
+var total;
+
function doSomething() {
for (var i = 0; i < 10000; ++i)
Math.sin(90);
}
+
+function doIncrement() {
+ total = 0;
+ for (var i = 0; i < 100000; ++i)
+ total += incVar;
+}
diff --git a/tests/benchmarks/declarative/script/data/global_prop.qml b/tests/benchmarks/declarative/script/data/global_prop.qml
index 908cecf..4fb7ee7 100644
--- a/tests/benchmarks/declarative/script/data/global_prop.qml
+++ b/tests/benchmarks/declarative/script/data/global_prop.qml
@@ -46,9 +46,8 @@ Rectangle {
width: 200; height: 200
signal triggered
- onTriggered: Program.doSomething();
+ signal incrementTriggered
- function doSomething() {
- Program.doSomething();
- }
+ onTriggered: Program.doSomething();
+ onIncrementTriggered: Program.doIncrement();
}
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
index 16052fa..5a7e151 100644
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ b/tests/benchmarks/declarative/script/tst_script.cpp
@@ -96,6 +96,8 @@ private slots:
void global_property_js();
void global_property_qml();
void global_property_qml_js();
+
+ void scriptfile_property();
};
inline QUrl TEST_FILE(const QString &filename)
@@ -678,6 +680,23 @@ void tst_script::global_property_qml_js()
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)