aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2015-09-22 14:08:24 +0200
committerGunnar Sletta <gunnar@sletta.org>2015-09-22 14:08:24 +0200
commit5dcc804ead9717dedc4a18d82ea4b25dfa557170 (patch)
tree8c88a91f4355a38df34bdae57f8b8376083ac8b6
parentc893c7b01094171c463e97a4fd84fa8a8879a583 (diff)
add some js benchmarks
-rw-r--r--benchmark/js/fib10.qml29
-rw-r--r--benchmark/js/sum10k.qml29
2 files changed, 58 insertions, 0 deletions
diff --git a/benchmark/js/fib10.qml b/benchmark/js/fib10.qml
new file mode 100644
index 0000000..386d0c7
--- /dev/null
+++ b/benchmark/js/fib10.qml
@@ -0,0 +1,29 @@
+import QtQuick 2.0
+
+Item {
+ id: root;
+ property int count: 50;
+
+ property real t;
+ NumberAnimation on t { from: 0; to: 1; duration: 1000; loops: Animation.Infinite }
+ onTChanged: {
+ repeater.model = 0;
+ repeater.model = root.count
+ }
+
+ Component.onCompleted: repeater.model = root.count
+
+ function fib(n) {
+ if (n < 2)
+ return Math.max(0, n);
+ else
+ return fib(n-1) + fib(n-2);
+ }
+
+ Repeater {
+ id: repeater
+ Item {
+ x: fib(10);
+ }
+ }
+}
diff --git a/benchmark/js/sum10k.qml b/benchmark/js/sum10k.qml
new file mode 100644
index 0000000..4e8f939
--- /dev/null
+++ b/benchmark/js/sum10k.qml
@@ -0,0 +1,29 @@
+import QtQuick 2.0
+
+Item {
+ id: root;
+ property int count: 50;
+
+ property real t;
+ NumberAnimation on t { from: 0; to: 1; duration: 1000; loops: Animation.Infinite }
+ onTChanged: {
+ repeater.model = 0;
+ repeater.model = root.count
+ }
+
+ Component.onCompleted: repeater.model = root.count
+
+ function sum(n) {
+ var x = 0;
+ for (var i=0; i<n; ++i)
+ x = x + x;
+ return x;
+ }
+
+ Repeater {
+ id: repeater
+ Item {
+ x: sum(10000);
+ }
+ }
+}