From 4f50ab594aa2fb1d38981127beca634ad3396489 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 17 Apr 2013 11:27:17 +1000 Subject: Add fine-grained QML / QtQuick performance benchmarks This commit adds a series of benchmarks to test the performance of fundamental areas of the QML engine (compilation, instantiation, binding evaluation, positioning) using types provided by the QtQuick QML module. Change-Id: Iecec058c45aea0bd728f03123fa2aa79d6af8efa Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com> Reviewed-by: Christopher Adams --- .../data/absolutepositioning.2.qml | 126 +++++++ .../data/absolutepositioning.qml | 119 ++++++ .../data/anchoredpositioning.2.qml | 91 +++++ .../data/anchoredpositioning.qml | 84 +++++ .../data/anchorwithbindingpositioning.2.qml | 83 +++++ .../data/anchorwithbindingpositioning.qml | 76 ++++ .../data/anchorwithgridpositioning.2.qml | 93 +++++ .../data/anchorwithgridpositioning.qml | 86 +++++ .../data/animations.1.qml | 6 + .../data/animations.2.qml | 11 + .../data/animations.3.qml | 11 + .../data/animations.4.qml | 15 + .../data/bindingpositioning.2.qml | 82 +++++ .../data/bindingpositioning.qml | 75 ++++ .../data/bindingwithgridpositioning.2.qml | 85 +++++ .../data/bindingwithgridpositioning.qml | 76 ++++ .../data/expression.1.qml | 13 + .../data/expression.2.qml | 19 + .../data/expression.3.qml | 14 + .../data/expression.4.qml | 19 + .../data/flickable.1.qml | 4 + .../data/flickable.2.qml | 6 + .../data/flickable.3.qml | 15 + .../qml/librarymetrics_performance/data/green.png | Bin 0 -> 314 bytes .../qml/librarymetrics_performance/data/grid.1.qml | 11 + .../librarymetrics_performance/data/image.1.qml | 4 + .../librarymetrics_performance/data/image.2.qml | 6 + .../librarymetrics_performance/data/image.3.qml | 7 + .../librarymetrics_performance/data/image.4.qml | 8 + .../qml/librarymetrics_performance/data/item.1.qml | 4 + .../librarymetrics_performance/data/item.10.qml | 5 + .../librarymetrics_performance/data/item.11.qml | 5 + .../librarymetrics_performance/data/item.12.qml | 5 + .../librarymetrics_performance/data/item.13.qml | 5 + .../librarymetrics_performance/data/item.14.qml | 8 + .../librarymetrics_performance/data/item.15.qml | 5 + .../librarymetrics_performance/data/item.16.qml | 5 + .../librarymetrics_performance/data/item.17.qml | 5 + .../librarymetrics_performance/data/item.18.qml | 7 + .../librarymetrics_performance/data/item.19.qml | 5 + .../qml/librarymetrics_performance/data/item.2.qml | 5 + .../librarymetrics_performance/data/item.20.qml | 12 + .../librarymetrics_performance/data/item.21.qml | 18 + .../librarymetrics_performance/data/item.22.qml | 11 + .../librarymetrics_performance/data/item.23.qml | 5 + .../librarymetrics_performance/data/item.24.qml | 6 + .../librarymetrics_performance/data/item.25.qml | 6 + .../qml/librarymetrics_performance/data/item.3.qml | 5 + .../qml/librarymetrics_performance/data/item.4.qml | 5 + .../qml/librarymetrics_performance/data/item.5.qml | 5 + .../qml/librarymetrics_performance/data/item.6.qml | 5 + .../qml/librarymetrics_performance/data/item.7.qml | 5 + .../qml/librarymetrics_performance/data/item.8.qml | 5 + .../qml/librarymetrics_performance/data/item.9.qml | 5 + .../librarymetrics_performance/data/listview.1.qml | 4 + .../librarymetrics_performance/data/listview.2.qml | 10 + .../librarymetrics_performance/data/listview.3.qml | 27 ++ .../data/mousearea.1.qml | 4 + .../data/mousearea.2.qml | 6 + .../data/mousearea.3.qml | 10 + .../data/nopositioning.2.qml | 73 ++++ .../data/nopositioning.qml | 67 ++++ .../data/rectangle.1.qml | 4 + .../data/rectangle.2.qml | 6 + .../data/rectangle.3.qml | 7 + .../librarymetrics_performance/data/repeater.1.qml | 13 + .../librarymetrics_performance/data/repeater.2.qml | 13 + .../librarymetrics_performance/data/states.1.qml | 24 ++ .../librarymetrics_performance/data/states.2.qml | 28 ++ .../qml/librarymetrics_performance/data/text.1.qml | 4 + .../qml/librarymetrics_performance/data/text.2.qml | 6 + .../qml/librarymetrics_performance/data/text.3.qml | 7 + .../librarymetrics_performance.pro | 9 + .../tst_librarymetrics_performance.cpp | 408 +++++++++++++++++++++ 74 files changed, 2132 insertions(+) create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/animations.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/animations.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/animations.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/animations.4.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/expression.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/expression.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/expression.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/expression.4.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/flickable.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/flickable.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/flickable.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/green.png create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/grid.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/image.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/image.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/image.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/image.4.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.10.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.11.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.12.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.13.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.14.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.15.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.16.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.17.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.18.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.19.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.20.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.21.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.22.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.23.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.24.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.25.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.4.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.5.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.6.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.7.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.8.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/item.9.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/listview.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/listview.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/listview.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/mousearea.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/mousearea.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/mousearea.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/rectangle.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/rectangle.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/rectangle.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/repeater.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/repeater.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/states.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/states.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/text.1.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/text.2.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/data/text.3.qml create mode 100644 tests/benchmarks/qml/librarymetrics_performance/librarymetrics_performance.pro create mode 100644 tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.2.qml new file mode 100644 index 0000000000..479e94c38a --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.2.qml @@ -0,0 +1,126 @@ +import QtQuick 2.0 + +// positioning all elements manually. +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: 400 + height: 400 + y: 400 + + Rectangle { + id: n1 + color: "green" + width: 200 + height: 100 + x: 0 + y: 200 + } + + Rectangle { + id: n2 + color: "cyan" + width: 200 + height: 100 + x: 200 + y: 200 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: 200 + height: 100 + x: 0 + y: 300 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: 200 + height: 100 + x: 200 + y: 300 + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // // expand + // p.height = 800 + // c.height = 400 + // c.y = 400 + // n1.height = 100 + // n1.y = 200 + // n2.height = 100 + // n2.y = 200 + // n3.height = 100 + // n3.y = 300 + // n4.height = 100 + // n4.y = 300 + // } else { + // count = 0; + // // shrink + // p.height = 400 + // c.height = 200 + // c.y = 200 + // n1.height = 50 + // n1.y = 100 + // n2.height = 50 + // n2.y = 100 + // n3.height = 50 + // n3.y = 150 + // n4.height = 50 + // n4.y = 150 + // } + // } + //} + + Component.onCompleted: { + var iterations = 10000; + //var t0 = new Date(); + while (iterations > 0) { + iterations--; + // expand + p.height = 800 + c.height = 400 + c.y = 400 + n1.height = 100 + n1.y = 200 + n2.height = 100 + n2.y = 200 + n3.height = 100 + n3.y = 300 + n4.height = 100 + n4.y = 300 + // shrink + p.height = 400 + c.height = 200 + c.y = 200 + n1.height = 50 + n1.y = 100 + n2.height = 50 + n2.y = 100 + n3.height = 50 + n3.y = 150 + n4.height = 50 + n4.y = 150 + } + //var t1 = new Date(); + //console.log("Absolute Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.qml b/tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.qml new file mode 100644 index 0000000000..9dac3a5fd0 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/absolutepositioning.qml @@ -0,0 +1,119 @@ +import QtQuick 2.0 + +// positioning all elements manually. +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: 400 + height: 400 + y: 400 + + Rectangle { + id: n1 + color: "green" + width: 200 + height: 100 + x: 0 + y: 200 + } + + Rectangle { + id: n2 + color: "cyan" + width: 200 + height: 100 + x: 200 + y: 200 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: 200 + height: 100 + x: 0 + y: 300 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: 200 + height: 100 + x: 200 + y: 300 + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // // expand + // p.height = 800 + // c.height = 400 + // c.y = 400 + // n1.height = 100 + // n1.y = 200 + // n2.height = 100 + // n2.y = 200 + // n3.height = 100 + // n3.y = 300 + // n4.height = 100 + // n4.y = 300 + // } else { + // count = 0; + // // shrink + // p.height = 400 + // c.height = 200 + // c.y = 200 + // n1.height = 50 + // n1.y = 100 + // n2.height = 50 + // n2.y = 100 + // n3.height = 50 + // n3.y = 150 + // n4.height = 50 + // n4.y = 150 + // } + // } + //} + + Component.onCompleted: { + // expand + p.height = 800 + c.height = 400 + c.y = 400 + n1.height = 100 + n1.y = 200 + n2.height = 100 + n2.y = 200 + n3.height = 100 + n3.y = 300 + n4.height = 100 + n4.y = 300 + // shrink + p.height = 400 + c.height = 200 + c.y = 200 + n1.height = 50 + n1.y = 100 + n2.height = 50 + n2.y = 100 + n3.height = 50 + n3.y = 150 + n4.height = 50 + n4.y = 150 + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.2.qml new file mode 100644 index 0000000000..592b37dfc7 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.2.qml @@ -0,0 +1,91 @@ +import QtQuick 2.0 + +// positioning via anchors +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + anchors.top: p.verticalCenter + anchors.bottom: p.bottom + anchors.left: p.left + anchors.right: p.right + + Rectangle { + id: g + anchors.top: c.verticalCenter + anchors.bottom: c.bottom + anchors.left: c.left + anchors.right: c.right + + Rectangle { + id: n1 + color: "green" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n2 + color: "cyan" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.horizontalCenter + anchors.right: g.right + } + + Rectangle { + id: n3 + color: "aquamarine" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n4 + color: "lightgreen" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.horizontalCenter + anchors.right: g.right + } + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + var iterations = 10000; + //var t0 = new Date(); + while (iterations > 0) { + iterations--; + p.height = 800; + p.height = 400; + } + //var t1 = new Date(); + //console.log("Anchored Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.qml b/tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.qml new file mode 100644 index 0000000000..36227ac962 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/anchoredpositioning.qml @@ -0,0 +1,84 @@ +import QtQuick 2.0 + +// positioning via anchors +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + anchors.top: p.verticalCenter + anchors.bottom: p.bottom + anchors.left: p.left + anchors.right: p.right + + Rectangle { + id: g + anchors.top: c.verticalCenter + anchors.bottom: c.bottom + anchors.left: c.left + anchors.right: c.right + + Rectangle { + id: n1 + color: "green" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n2 + color: "cyan" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.horizontalCenter + anchors.right: g.right + } + + Rectangle { + id: n3 + color: "aquamarine" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n4 + color: "lightgreen" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.horizontalCenter + anchors.right: g.right + } + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + p.height = 800; + p.height = 400; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.2.qml new file mode 100644 index 0000000000..33483ca9e5 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.2.qml @@ -0,0 +1,83 @@ +import QtQuick 2.0 + +// positioning via anchors contaminated with a binding +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + anchors.top: p.verticalCenter + anchors.bottom: p.bottom + anchors.left: p.left + anchors.right: p.right + + Rectangle { + id: n1 + color: "green" + height: c.height / 4 + anchors.top: c.verticalCenter + anchors.left: c.left + anchors.right: c.horizontalCenter + } + + Rectangle { + id: n2 + color: "cyan" + anchors.top: c.verticalCenter + anchors.bottom: n1.bottom + anchors.left: c.horizontalCenter + anchors.right: c.right + } + + Rectangle { + id: n3 + color: "aquamarine" + anchors.top: n1.bottom + anchors.bottom: c.bottom + anchors.left: c.left + anchors.right: c.horizontalCenter + } + + Rectangle { + id: n4 + color: "lightgreen" + anchors.top: n1.bottom + anchors.bottom: c.bottom + anchors.left: c.horizontalCenter + anchors.right: c.right + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + var iterations = 10000; + //var t0 = new Date(); + while (iterations > 0) { + iterations--; + p.height = 800; + p.height = 400; + } + //var t1 = new Date(); + //console.log("Anchor With Binding Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.qml b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.qml new file mode 100644 index 0000000000..d05a089a81 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithbindingpositioning.qml @@ -0,0 +1,76 @@ +import QtQuick 2.0 + +// positioning via anchors contaminated with a binding +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + anchors.top: p.verticalCenter + anchors.bottom: p.bottom + anchors.left: p.left + anchors.right: p.right + + Rectangle { + id: n1 + color: "green" + height: c.height / 4 + anchors.top: c.verticalCenter + anchors.left: c.left + anchors.right: c.horizontalCenter + } + + Rectangle { + id: n2 + color: "cyan" + anchors.top: c.verticalCenter + anchors.bottom: n1.bottom + anchors.left: c.horizontalCenter + anchors.right: c.right + } + + Rectangle { + id: n3 + color: "aquamarine" + anchors.top: n1.bottom + anchors.bottom: c.bottom + anchors.left: c.left + anchors.right: c.horizontalCenter + } + + Rectangle { + id: n4 + color: "lightgreen" + anchors.top: n1.bottom + anchors.bottom: c.bottom + anchors.left: c.horizontalCenter + anchors.right: c.right + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + p.height = 800; + p.height = 400; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.2.qml new file mode 100644 index 0000000000..7c0d868e82 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.2.qml @@ -0,0 +1,93 @@ +import QtQuick 2.0 + +// positioning via anchors with a grid +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + anchors.top: p.verticalCenter + anchors.bottom: p.bottom + anchors.left: p.left + anchors.right: p.right + + Grid { + id: g + rows: 2 + columns: 2 + anchors.top: c.verticalCenter + anchors.bottom: c.bottom + anchors.left: c.left + anchors.right: c.right + + Rectangle { + id: n1 + color: "green" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n2 + color: "cyan" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.horizontalCenter + anchors.right: g.right + } + + Rectangle { + id: n3 + color: "aquamarine" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n4 + color: "lightgreen" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.horizontalCenter + anchors.right: g.right + } + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + var iterations = 10000; + //var t0 = new Date(); + while (iterations > 0) { + iterations--; + p.height = 800; + p.height = 400; + } + //var t1 = new Date(); + //console.log("Anchor With Grid Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.qml b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.qml new file mode 100644 index 0000000000..bc98d95e87 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/anchorwithgridpositioning.qml @@ -0,0 +1,86 @@ +import QtQuick 2.0 + +// positioning via anchors with a grid +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + anchors.top: p.verticalCenter + anchors.bottom: p.bottom + anchors.left: p.left + anchors.right: p.right + + Grid { + id: g + rows: 2 + columns: 2 + anchors.top: c.verticalCenter + anchors.bottom: c.bottom + anchors.left: c.left + anchors.right: c.right + + Rectangle { + id: n1 + color: "green" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n2 + color: "cyan" + anchors.top: g.top + anchors.bottom: g.verticalCenter + anchors.left: g.horizontalCenter + anchors.right: g.right + } + + Rectangle { + id: n3 + color: "aquamarine" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.left + anchors.right: g.horizontalCenter + } + + Rectangle { + id: n4 + color: "lightgreen" + anchors.top: g.verticalCenter + anchors.bottom: g.bottom + anchors.left: g.horizontalCenter + anchors.right: g.right + } + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + p.height = 800; + p.height = 400; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/animations.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/animations.1.qml new file mode 100644 index 0000000000..846378fdee --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/animations.1.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Item { + property real a: 50 + NumberAnimation on a { to: 500; duration: 1000 } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/animations.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/animations.2.qml new file mode 100644 index 0000000000..9bba3a3091 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/animations.2.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: root + property real a: 50 + SequentialAnimation { + id: anim + ScriptAction { script: root.a += 5; } + ScriptAction { script: root.a += 15; } + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/animations.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/animations.3.qml new file mode 100644 index 0000000000..b0c5b33cd7 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/animations.3.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: root + property real a: 50 + ParallelAnimation { + id: anim + ScriptAction { script: root.a += 5; } + ScriptAction { script: root.a += 15; } + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/animations.4.qml b/tests/benchmarks/qml/librarymetrics_performance/data/animations.4.qml new file mode 100644 index 0000000000..877cf4dd14 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/animations.4.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Item { + id: root + property real a: 50 + SequentialAnimation { + id: anim + ScriptAction { script: root.a += 5; } + ScriptAction { script: root.a += 15; } + } + + Component.onCompleted: { + anim.start(); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.2.qml new file mode 100644 index 0000000000..5c16196f07 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.2.qml @@ -0,0 +1,82 @@ +import QtQuick 2.0 + +// positioning done with bindings +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: p.width + height: p.height / 2 + y: p.height / 2 + + Rectangle { + id: n1 + color: "green" + width: c.width / 2 + height: c.height / 4 + x: 0 + y: c.height / 2 + } + + Rectangle { + id: n2 + color: "cyan" + width: c.width / 2 + height: c.height / 4 + x: c.width / 2 + y: c.height / 2 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: c.width / 2 + height: c.height / 4 + x: 0 + y: (c.height / 4) * 3 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: c.width / 2 + height: c.height / 4 + x: c.width / 2 + y: (c.height / 4) * 3 + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + var iterations = 10000; + //var t0 = new Date(); + while (iterations > 0) { + iterations--; + p.height = 800; + p.height = 400; + } + //var t1 = new Date(); + //console.log("Binding Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.qml b/tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.qml new file mode 100644 index 0000000000..0c60d1e53b --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/bindingpositioning.qml @@ -0,0 +1,75 @@ +import QtQuick 2.0 + +// positioning done with bindings +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: p.width + height: p.height / 2 + y: p.height / 2 + + Rectangle { + id: n1 + color: "green" + width: c.width / 2 + height: c.height / 4 + x: 0 + y: c.height / 2 + } + + Rectangle { + id: n2 + color: "cyan" + width: c.width / 2 + height: c.height / 4 + x: c.width / 2 + y: c.height / 2 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: c.width / 2 + height: c.height / 4 + x: 0 + y: (c.height / 4) * 3 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: c.width / 2 + height: c.height / 4 + x: c.width / 2 + y: (c.height / 4) * 3 + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + p.height = 800; + p.height = 400; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.2.qml new file mode 100644 index 0000000000..1e39a4fbb2 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.2.qml @@ -0,0 +1,85 @@ +import QtQuick 2.0 + +// positioning via bindings with a grid +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: p.width + height: p.height / 2 + y: p.height / 2 + + Grid { + id: g + rows: 2 + columns: 2 + width: c.width + height: c.height / 2 + y: c.height / 2 + + Rectangle { + id: n1 + color: "green" + width: g.width/2 + height: g.height/2 + } + + Rectangle { + id: n2 + color: "cyan" + width: g.width/2 + height: g.height/2 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: g.width/2 + height: g.height/2 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: g.width/2 + height: g.height/2 + } + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + var iterations = 10000; + //var t0 = new Date(); + while (iterations > 0) { + iterations--; + // expand + p.height = 800; + // shrink + p.height = 400; + } + //var t1 = new Date(); + //console.log("Binding With Grid Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.qml b/tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.qml new file mode 100644 index 0000000000..ef481ed55c --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/bindingwithgridpositioning.qml @@ -0,0 +1,76 @@ +import QtQuick 2.0 + +// positioning via bindings with a grid +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: p.width + height: p.height / 2 + y: p.height / 2 + + Grid { + id: g + rows: 2 + columns: 2 + width: c.width + height: c.height / 2 + y: c.height / 2 + + Rectangle { + id: n1 + color: "green" + width: g.width/2 + height: g.height/2 + } + + Rectangle { + id: n2 + color: "cyan" + width: g.width/2 + height: g.height/2 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: g.width/2 + height: g.height/2 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: g.width/2 + height: g.height/2 + } + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + p.height = 800; + p.height = 400; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/expression.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/expression.1.qml new file mode 100644 index 0000000000..f6eaf39675 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/expression.1.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + property int a: 0 + function someFunc() { + var tmp = 5; + var another = tmp * 5 + 3; + var yetanother = another % 5; + if (yetanother > 2) a = 42; + else a = 9000; + return 42; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/expression.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/expression.2.qml new file mode 100644 index 0000000000..6664156c4f --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/expression.2.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + property int a: 0 + property int b: 0 + + function someFunc() { + var tmp = 5; + var another = tmp * 5 + 3; + var yetanother = another % 5; + if (yetanother > 2) a = 42; + else a = 9000; + return 42; + } + + Component.onCompleted: { + b = someFunc(); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/expression.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/expression.3.qml new file mode 100644 index 0000000000..e6b5e934ea --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/expression.3.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + property int a: 5 + property int b: 0 + + function someFunc() { + b += a; + } + + Component.onCompleted: { + onAChanged.connect(someFunc) + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/expression.4.qml b/tests/benchmarks/qml/librarymetrics_performance/data/expression.4.qml new file mode 100644 index 0000000000..bcfc381c79 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/expression.4.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + property int a: 5 + property int d: 12 + signal trigger(int b, int c) + + onAChanged: { + trigger(a*2, 15+a) + } + + function someFunc(b, c) { + d = b+c; + } + + Component.onCompleted: { + trigger.connect(someFunc); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/flickable.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/flickable.1.qml new file mode 100644 index 0000000000..cbec44bb4f --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/flickable.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Flickable { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/flickable.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/flickable.2.qml new file mode 100644 index 0000000000..2257680c34 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/flickable.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Flickable { + width: 320 + height: 480 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/flickable.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/flickable.3.qml new file mode 100644 index 0000000000..956103eef7 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/flickable.3.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Flickable { + width: 320 + height: 480 + contentWidth: c1.width + contentHeight: c1.height + + Rectangle { + id: c1 + width: 500 + height: 1000 + color: "blue" + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/green.png b/tests/benchmarks/qml/librarymetrics_performance/data/green.png new file mode 100644 index 0000000000..0a2e153ba1 Binary files /dev/null and b/tests/benchmarks/qml/librarymetrics_performance/data/green.png differ diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/grid.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/grid.1.qml new file mode 100644 index 0000000000..d29d1fad19 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/grid.1.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Grid { + columns: 3 + spacing: 2 + Rectangle { color: "red"; width: 50; height: 50 } + Rectangle { color: "green"; width: 20; height: 50 } + Rectangle { color: "blue"; width: 50; height: 20 } + Rectangle { color: "cyan"; width: 50; height: 50 } + Rectangle { color: "magenta"; width: 10; height: 10 } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/image.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/image.1.qml new file mode 100644 index 0000000000..9be39f8445 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/image.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Image { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/image.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/image.2.qml new file mode 100644 index 0000000000..7581cf1970 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/image.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Image { + width: 320 + height: 480 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/image.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/image.3.qml new file mode 100644 index 0000000000..beede811ff --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/image.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Image { + width: 320 + height: 480 + source: "green.png" +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/image.4.qml b/tests/benchmarks/qml/librarymetrics_performance/data/image.4.qml new file mode 100644 index 0000000000..7031dca0bf --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/image.4.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Image { + width: 320 + height: 480 + source: "green.png" + asynchronous: true +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.1.qml new file mode 100644 index 0000000000..459c82afbb --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Item { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.10.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.10.qml new file mode 100644 index 0000000000..5a50be2bf1 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.10.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property bool a: true +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.11.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.11.qml new file mode 100644 index 0000000000..1e2b6eab29 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.11.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property string a: "hello, world" +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.12.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.12.qml new file mode 100644 index 0000000000..f026c1f305 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.12.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property real a: 42.42 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.13.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.13.qml new file mode 100644 index 0000000000..6ca798ef66 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.13.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property variant a: Qt.rgba(0.3, 0.4, 0.5, 0.6) +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.14.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.14.qml new file mode 100644 index 0000000000..2f9a951409 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.14.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Item { + Item { + id: c1 + } + property Item a: c1 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.15.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.15.qml new file mode 100644 index 0000000000..f18738955f --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.15.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property var a: 5 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.16.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.16.qml new file mode 100644 index 0000000000..b37ac77f05 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.16.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property var a: function() { return 6; } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.17.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.17.qml new file mode 100644 index 0000000000..ad0de266a3 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.17.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property var a: { "tag": "test" } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.18.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.18.qml new file mode 100644 index 0000000000..b77a760f6c --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.18.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + property int a: b + c + property int b: 2 + property int c: 40 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.19.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.19.qml new file mode 100644 index 0000000000..66e77fdefb --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.19.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property int a: if (true) 5; +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.2.qml new file mode 100644 index 0000000000..c08c692c91 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property int a +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.20.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.20.qml new file mode 100644 index 0000000000..9b1bd56fe1 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.20.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + Item { + id: c1 + function someFunc() { return 42; } + property int b: someFunc() + } + property alias c1bAlias: c1.b + + property int a: c1bAlias * 5 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.21.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.21.qml new file mode 100644 index 0000000000..4a423fd1fd --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.21.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + id: root + objectName: "root" + function generate() { + var f = null; + if (root.objectName == "root") { + f = function(param) { return 42 - param; } + } else { + f = function(param) { return 9000 * param; } + } + return f; + } + + property int b: 50 + property var a: b + generate()() +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.22.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.22.qml new file mode 100644 index 0000000000..7cd408f660 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.22.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + property int b: 100 + property int c: 15 + property int a: 15 + onAChanged: { + if (b >= 100) b = 12; + else c += a; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.23.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.23.qml new file mode 100644 index 0000000000..837f137ce3 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.23.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 +import ModuleApi 1.0 as ModApi + +Item { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.24.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.24.qml new file mode 100644 index 0000000000..63a53dbe0d --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.24.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import ModuleApi 1.0 as ModApi + +Item { + property int a: ModApi.ModuleApi.intProp +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.25.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.25.qml new file mode 100644 index 0000000000..a690761c94 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.25.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import ModuleApi 1.0 as ModApi + +Item { + property int a: ModApi.ModuleApi.intFunc() +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.3.qml new file mode 100644 index 0000000000..b0c43b142d --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property bool a +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.4.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.4.qml new file mode 100644 index 0000000000..fb1586ce2f --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.4.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property string a +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.5.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.5.qml new file mode 100644 index 0000000000..c6030addfa --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.5.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property real a +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.6.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.6.qml new file mode 100644 index 0000000000..acc8d17ca0 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.6.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property variant a +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.7.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.7.qml new file mode 100644 index 0000000000..cf566e37e2 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.7.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property Item a +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.8.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.8.qml new file mode 100644 index 0000000000..449d6b3f01 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.8.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property var a +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/item.9.qml b/tests/benchmarks/qml/librarymetrics_performance/data/item.9.qml new file mode 100644 index 0000000000..7875097b04 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/item.9.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property int a: 42 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/listview.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/listview.1.qml new file mode 100644 index 0000000000..617f66742f --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/listview.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +ListView { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/listview.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/listview.2.qml new file mode 100644 index 0000000000..095b026fd2 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/listview.2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + ListView { + anchors.fill: parent + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/listview.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/listview.3.qml new file mode 100644 index 0000000000..9573adba1a --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/listview.3.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + ListView { + anchors.fill: parent + model: simpleModel + delegate: Text { + text: name + } + } + + ListModel { + id: simpleModel + ListElement { + name: "first" + } + ListElement { + name: "second" + } + ListElement { + name: "third" + } + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.1.qml new file mode 100644 index 0000000000..71a522ea6c --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +MouseArea { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.2.qml new file mode 100644 index 0000000000..55c6be361a --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +MouseArea { + width: 320 + height: 480 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.3.qml new file mode 100644 index 0000000000..91b2718011 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/mousearea.3.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +MouseArea { + width: 320 + height: 480 + property int clickCount: 0 + onClicked: { + clickCount++; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.2.qml new file mode 100644 index 0000000000..2edda352ef --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.2.qml @@ -0,0 +1,73 @@ +import QtQuick 2.0 + +// no bindings or anchors. +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: 400 + height: 200 + + Rectangle { + id: n1 + color: "green" + width: 200 + height: 50 + } + + Rectangle { + id: n2 + color: "cyan" + width: 200 + height: 50 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: 200 + height: 50 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: 200 + height: 50 + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + var iterations = 10000; + //var t0 = new Date(); + while (iterations > 0) { + iterations--; + p.height = 800; + p.height = 400; + } + //var t1 = new Date(); + //console.log("No Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.qml b/tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.qml new file mode 100644 index 0000000000..2fda6ca437 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/nopositioning.qml @@ -0,0 +1,67 @@ +import QtQuick 2.0 + +// no bindings or anchors. +Rectangle { + id: p + color: "red" + width: 400 + height: 800 + + Rectangle { + id: c + color: "blue" + width: 400 + height: 200 + + Rectangle { + id: n1 + color: "green" + width: 200 + height: 50 + } + + Rectangle { + id: n2 + color: "cyan" + width: 200 + height: 50 + } + + Rectangle { + id: n3 + color: "aquamarine" + width: 200 + height: 50 + } + + Rectangle { + id: n4 + color: "lightgreen" + width: 200 + height: 50 + } + } + + // for visually determining correctness. + //Timer { + // property int count: 0 + // interval: 1000 + // running: true + // repeat: true + // onTriggered: { + // if (count == 0) { + // count = 1; + // p.height = 800; + // } else { + // count = 0; + // p.height = 400; + // } + // } + //} + + Component.onCompleted: { + // we trigger just two position updates. + p.height = 800; + p.height = 400; + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.1.qml new file mode 100644 index 0000000000..011702bbc8 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Rectangle { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.2.qml new file mode 100644 index 0000000000..40cca530bb --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.3.qml new file mode 100644 index 0000000000..19d702774d --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/rectangle.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "red" +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/repeater.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/repeater.1.qml new file mode 100644 index 0000000000..9c935cf9a8 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/repeater.1.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Row { + Repeater { + model: 3 + Rectangle { + width: 100 + height: 40 + border.width: 2 + color: "red" + } + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/repeater.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/repeater.2.qml new file mode 100644 index 0000000000..e413279e02 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/repeater.2.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Column { + Repeater { + model: 3 + Rectangle { + width: 100 + height: 40 + border.width: 2 + color: "red" + } + } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/states.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/states.1.qml new file mode 100644 index 0000000000..9c5f038197 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/states.1.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + id: root + width: 320 + height: 480 + + property real a: 200 + property real b: 10 + + states: [ + State { + name: "first" + PropertyChanges { target: root; onBChanged: setA_1() } + }, + State { + name: "second" + PropertyChanges { target: root; onBChanged: setA_2() } + } + ] + + function setA_1() { a = 50; } + function setA_2() { a = 100; } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/states.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/states.2.qml new file mode 100644 index 0000000000..449d244058 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/states.2.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Item { + id: root + width: 320 + height: 480 + + property real a: 200 + property real b: 10 + + states: [ + State { + name: "first" + PropertyChanges { target: root; onBChanged: setA_1() } + }, + State { + name: "second" + PropertyChanges { target: root; onBChanged: setA_2() } + } + ] + + transitions: Transition { + NumberAnimation { property: "a"; easing.type: Easing.InOutQuad } + } + + function setA_1() { a = 50; } + function setA_2() { a = 100; } +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/text.1.qml b/tests/benchmarks/qml/librarymetrics_performance/data/text.1.qml new file mode 100644 index 0000000000..d68e6e154b --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/text.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Text { +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/text.2.qml b/tests/benchmarks/qml/librarymetrics_performance/data/text.2.qml new file mode 100644 index 0000000000..f77b9a9eea --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/text.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Text { + width: 320 + height: 480 +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/data/text.3.qml b/tests/benchmarks/qml/librarymetrics_performance/data/text.3.qml new file mode 100644 index 0000000000..8e15571687 --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/data/text.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Text { + width: 320 + height: 480 + text: "hello, world" +} diff --git a/tests/benchmarks/qml/librarymetrics_performance/librarymetrics_performance.pro b/tests/benchmarks/qml/librarymetrics_performance/librarymetrics_performance.pro new file mode 100644 index 0000000000..7cfa843a2f --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/librarymetrics_performance.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_librarymetrics_performance + +QT += qml quick network testlib +macx:CONFIG -= app_bundle + +CONFIG += release +SOURCES += tst_librarymetrics_performance.cpp diff --git a/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp b/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp new file mode 100644 index 0000000000..27ee97a04c --- /dev/null +++ b/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp @@ -0,0 +1,408 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +// This benchmark produces performance statistics +// for the standard set of elements, properties and expressions which +// are provided in the QtDeclarative library (QtQml and QtQuick). + +#define AVERAGE_OVER_N 10 +#define IGNORE_N_OUTLIERS 2 + +class ModuleApi : public QObject +{ + Q_OBJECT + Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged) + +public: + ModuleApi() : m_intProp(42) { } + ~ModuleApi() {} + + Q_INVOKABLE int intFunc() const { return 9000; } + int intProp() const { return m_intProp; } + void setIntProp(int v) { m_intProp = v; emit intPropChanged(); } + +signals: + void intPropChanged(); + +private: + int m_intProp; +}; + +static QObject *module_api_factory(QQmlEngine*, QJSEngine*) +{ + return new ModuleApi; +} + +class tst_librarymetrics_performance : public QObject +{ + Q_OBJECT + +public: + tst_librarymetrics_performance(); + ~tst_librarymetrics_performance(); + +private slots: + void initTestCase() {} + + // ---------------------- performance tests: + void compilation(); + void instantiation_cached(); + void instantiation(); + void positioners(); + + // ---------------------- test row data: + void metrics_data(); + void compilation_data() { metrics_data(); } + void instantiation_cached_data() { metrics_data(); } + void instantiation_data() { metrics_data(); } + void positioners_data(); + +private: + QQmlEngine *e; +}; + +static void cleanState(QQmlEngine **e) +{ + delete *e; + qmlClearTypeRegistrations(); + *e = new QQmlEngine; + qmlRegisterSingletonType("ModuleApi", 1, 0, "ModuleApi", module_api_factory);//Speed of qmlRegister not covered in this benchmark + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + +tst_librarymetrics_performance::tst_librarymetrics_performance() + : e(new QQmlEngine) +{ +} + +tst_librarymetrics_performance::~tst_librarymetrics_performance() +{ + cleanState(&e); +} + +static QUrl testFileUrl(const char * filename) +{ + return QUrl::fromLocalFile(QString(QLatin1String(filename))); +} + +void tst_librarymetrics_performance::metrics_data() +{ + // all of the tests follow the same basic format. + QTest::addColumn("qmlfile"); + + QTest::newRow("001) item - empty") << testFileUrl("data/item.1.qml"); + QTest::newRow("002) item - uninitialised int prop") << testFileUrl("data/item.2.qml"); + QTest::newRow("003) item - uninitialised bool prop") << testFileUrl("data/item.3.qml"); + QTest::newRow("004) item - uninitialised string prop") << testFileUrl("data/item.4.qml"); + QTest::newRow("005) item - uninitialised real prop") << testFileUrl("data/item.5.qml"); + QTest::newRow("006) item - uninitialised variant prop") << testFileUrl("data/item.6.qml"); + QTest::newRow("007) item - uninitialised Item prop") << testFileUrl("data/item.7.qml"); + QTest::newRow("008) item - uninitialised var prop") << testFileUrl("data/item.8.qml"); + QTest::newRow("009) item - initialised int prop") << testFileUrl("data/item.9.qml"); + QTest::newRow("010) item - initialised bool prop") << testFileUrl("data/item.10.qml"); + QTest::newRow("011) item - initialised string prop") << testFileUrl("data/item.11.qml"); + QTest::newRow("012) item - initialised real prop") << testFileUrl("data/item.12.qml"); + QTest::newRow("013) item - initialised variant (value type) prop") << testFileUrl("data/item.13.qml"); + QTest::newRow("014) item - initialised Item prop (with child)") << testFileUrl("data/item.14.qml"); + QTest::newRow("015) item - initialised var prop with primitive") << testFileUrl("data/item.15.qml"); + QTest::newRow("016) item - initialised var prop with function") << testFileUrl("data/item.16.qml"); + QTest::newRow("017) item - initialised var prop with object") << testFileUrl("data/item.17.qml"); + QTest::newRow("018) item - int prop with optimized binding") << testFileUrl("data/item.18.qml"); + QTest::newRow("019) item - int prop with shared binding") << testFileUrl("data/item.19.qml"); + QTest::newRow("020) item - int prop with slow binding (alias and func)") << testFileUrl("data/item.20.qml"); + QTest::newRow("021) item - var prop with binding") << testFileUrl("data/item.21.qml"); + QTest::newRow("022) item - int prop with change signal") << testFileUrl("data/item.22.qml"); + QTest::newRow("023) item - importing module api") << testFileUrl("data/item.23.qml"); + QTest::newRow("024) item - accessing property of module api") << testFileUrl("data/item.24.qml"); + QTest::newRow("025) item - invoking function of module api") << testFileUrl("data/item.25.qml"); + + QTest::newRow("026) expression - item with unused dynamic function") << testFileUrl("data/expression.1.qml"); + QTest::newRow("027) expression - item with dynamic function called in onCompleted") << testFileUrl("data/expression.2.qml"); + QTest::newRow("027) expression - item with bound signal no params") << testFileUrl("data/expression.3.qml"); + QTest::newRow("027) expression - item with bound signal with params") << testFileUrl("data/expression.4.qml"); + + QTest::newRow("028) rectangle - empty") << testFileUrl("data/rectangle.1.qml"); + QTest::newRow("029) rectangle - with size") << testFileUrl("data/rectangle.2.qml"); + QTest::newRow("030) rectangle - with size and color") << testFileUrl("data/rectangle.3.qml"); + + QTest::newRow("031) text - empty") << testFileUrl("data/text.1.qml"); + QTest::newRow("032) text - with size") << testFileUrl("data/text.2.qml"); + QTest::newRow("033) text - with size and text") << testFileUrl("data/text.3.qml"); + + QTest::newRow("034) mouse area - empty") << testFileUrl("data/mousearea.1.qml"); + QTest::newRow("035) mouse area - with size") << testFileUrl("data/mousearea.2.qml"); + QTest::newRow("036) mouse area - with size and onClicked handler") << testFileUrl("data/mousearea.3.qml"); + + QTest::newRow("037) listView - empty") << testFileUrl("data/listview.1.qml"); + QTest::newRow("038) listView - with anchors but no content") << testFileUrl("data/listview.2.qml"); + QTest::newRow("039) listView - with anchors and list model content with delegate") << testFileUrl("data/listview.3.qml"); + + QTest::newRow("040) flickable - empty") << testFileUrl("data/flickable.1.qml"); + QTest::newRow("041) flickable - with size") << testFileUrl("data/flickable.2.qml"); + QTest::newRow("042) flickable - with some content") << testFileUrl("data/flickable.3.qml"); + + QTest::newRow("043) image - empty") << testFileUrl("data/image.1.qml"); + QTest::newRow("044) image - with size") << testFileUrl("data/image.2.qml"); + QTest::newRow("045) image - with content") << testFileUrl("data/image.3.qml"); + QTest::newRow("046) image - with content, async") << testFileUrl("data/image.4.qml"); + + QTest::newRow("047) states - two states, no transitions") << testFileUrl("data/states.1.qml"); + QTest::newRow("048) states - two states, with transition") << testFileUrl("data/states.2.qml"); + + QTest::newRow("049) animations - number animation") << testFileUrl("data/animations.1.qml"); + QTest::newRow("050) animations - sequential animation (scriptaction, scriptaction)") << testFileUrl("data/animations.2.qml"); + QTest::newRow("051) animations - parallel animation (scriptaction, scriptaction)") << testFileUrl("data/animations.3.qml"); + QTest::newRow("052) animations - sequential animation, started in onCompleted") << testFileUrl("data/animations.4.qml"); + + QTest::newRow("053) repeater - row - repeat simple rectangle") << testFileUrl("data/repeater.1.qml"); + QTest::newRow("054) repeater - column - repeat simple rectangle") << testFileUrl("data/repeater.2.qml"); + + QTest::newRow("055) grid - simple grid of rectangles") << testFileUrl("data/grid.1.qml"); + + QTest::newRow("056) positioning - no positioning") << testFileUrl("data/nopositioning.qml"); + QTest::newRow("057) positioning - absolute positioning") << testFileUrl("data/absolutepositioning.qml"); + QTest::newRow("058) positioning - anchored positioning") << testFileUrl("data/anchoredpositioning.qml"); + QTest::newRow("059) positioning - anchored (with grid) positioning") << testFileUrl("data/anchorwithgridpositioning.qml"); + QTest::newRow("060) positioning - binding positioning") << testFileUrl("data/bindingpositioning.qml"); + QTest::newRow("061) positioning - anchored (with binding) positioning") << testFileUrl("data/anchorwithbindingpositioning.qml"); + QTest::newRow("062) positioning - binding (with grid) positioning") << testFileUrl("data/bindingwithgridpositioning.qml"); +} + +void tst_librarymetrics_performance::compilation() +{ + QFETCH(QUrl, qmlfile); + + cleanState(&e); + { + // check that they can compile, before timing. + QQmlComponent c(e, this); + c.loadUrl(qmlfile); // just compile. + if (!c.errors().isEmpty()) { + qWarning() << "ERROR:" << c.errors(); + } + } + + QList nResults; + + // generate AVERAGE_OVER_N results + for (int i = 0; i < AVERAGE_OVER_N; ++i) { + cleanState(&e); + { + QElapsedTimer et; + et.start(); + QQmlComponent c(e, this); + c.loadUrl(qmlfile); // just compile. + qint64 etime = et.nsecsElapsed(); + nResults.append(etime); + } + } + + // sort the list + qSort(nResults); + + // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference) + for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) { + if (!nResults.isEmpty()) nResults.removeLast(); + if (!nResults.isEmpty()) nResults.removeLast(); + } + + // now generate an average + qint64 totaltime = 0; + if (nResults.size() == 0) nResults.append(9999); + for (int i = 0; i < nResults.size(); ++i) + totaltime += nResults.at(i); + double average = ((double)totaltime) / nResults.count(); + + // and return it as the result + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib +} + +void tst_librarymetrics_performance::instantiation_cached() +{ + QFETCH(QUrl, qmlfile); + + cleanState(&e); + QList nResults; + + // generate AVERAGE_OVER_N results + for (int i = 0; i < AVERAGE_OVER_N; ++i) { + QElapsedTimer et; + et.start(); + QQmlComponent c(e, this); + c.loadUrl(qmlfile); // just compile. + QObject *o = c.create(); + qint64 etime = et.nsecsElapsed(); + nResults.append(etime); + delete o; + } + + // sort the list + qSort(nResults); + + // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference) + for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) { + if (!nResults.isEmpty()) nResults.removeLast(); + if (!nResults.isEmpty()) nResults.removeLast(); + } + + // now generate an average + qint64 totaltime = 0; + if (nResults.size() == 0) nResults.append(9999); + for (int i = 0; i < nResults.size(); ++i) + totaltime += nResults.at(i); + double average = ((double)totaltime) / nResults.count(); + + // and return it as the result + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib +} + +void tst_librarymetrics_performance::instantiation() +{ + QFETCH(QUrl, qmlfile); + + cleanState(&e); + QList nResults; + + // generate AVERAGE_OVER_N results + for (int i = 0; i < AVERAGE_OVER_N; ++i) { + cleanState(&e); + { + QElapsedTimer et; + et.start(); + QQmlComponent c(e, this); + c.loadUrl(qmlfile); // just compile. + QObject *o = c.create(); + qint64 etime = et.nsecsElapsed(); + nResults.append(etime); + delete o; + } + } + + // sort the list + qSort(nResults); + + // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference) + for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) { + if (!nResults.isEmpty()) nResults.removeLast(); + if (!nResults.isEmpty()) nResults.removeLast(); + } + + // now generate an average + qint64 totaltime = 0; + if (nResults.size() == 0) nResults.append(9999); + for (int i = 0; i < nResults.size(); ++i) + totaltime += nResults.at(i); + double average = ((double)totaltime) / nResults.count(); + + // and return it as the result + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib +} + +void tst_librarymetrics_performance::positioners_data() +{ + QTest::addColumn("qmlfile"); + QTest::newRow("01) positioning - no positioning") << testFileUrl("data/nopositioning.2.qml"); + QTest::newRow("02) positioning - absolute positioning") << testFileUrl("data/absolutepositioning.2.qml"); + QTest::newRow("03) positioning - anchored positioning") << testFileUrl("data/anchoredpositioning.2.qml"); + QTest::newRow("04) positioning - anchored (with grid) positioning") << testFileUrl("data/anchorwithgridpositioning.2.qml"); + QTest::newRow("05) positioning - binding positioning") << testFileUrl("data/bindingpositioning.2.qml"); + QTest::newRow("06) positioning - anchored (with binding) positioning") << testFileUrl("data/anchorwithbindingpositioning.2.qml"); + QTest::newRow("07) positioning - binding (with grid) positioning") << testFileUrl("data/bindingwithgridpositioning.2.qml"); +} + +// this test triggers repositioning a large number of times, +// so we can track the cost of different repositioning methods. +void tst_librarymetrics_performance::positioners() +{ + QFETCH(QUrl, qmlfile); + + cleanState(&e); + QList nResults; + + // generate AVERAGE_OVER_N results + for (int i = 0; i < AVERAGE_OVER_N; ++i) { + cleanState(&e); + { + QElapsedTimer et; + et.start(); + QQmlComponent c(e, this); + c.loadUrl(qmlfile); // just compile. + QObject *o = c.create(); + qint64 etime = et.nsecsElapsed(); + nResults.append(etime); + delete o; + } + } + + // sort the list + qSort(nResults); + + // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference) + for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) { + if (!nResults.isEmpty()) nResults.removeLast(); + if (!nResults.isEmpty()) nResults.removeLast(); + } + + // now generate an average + qint64 totaltime = 0; + if (nResults.size() == 0) nResults.append(9999); + for (int i = 0; i < nResults.size(); ++i) + totaltime += nResults.at(i); + double average = ((double)totaltime) / nResults.count(); + + // and return it as the result + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); + QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib +} + +QTEST_MAIN(tst_librarymetrics_performance) + +#include "tst_librarymetrics_performance.moc" -- cgit v1.2.3