diff --git a/Qt_Performance_Benchmark/Rect.qml b/Qt_Performance_Benchmark/Rect.qml new file mode 100644 index 0000000..34f21b4 --- /dev/null +++ b/Qt_Performance_Benchmark/Rect.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + + + + + +Rectangle { + + function randomInteger(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } + + width:100 + height:100 + color:Qt.rgba(Math.random(),Math.random(),Math.random(),1); + NumberAnimation on x {loops: Animation.Infinite; from: randomInteger(0, 1920); to: randomInteger(0, 1920); duration: 500 } + NumberAnimation on y {loops: Animation.Infinite; from: randomInteger(0, 900); to: randomInteger(0, 900); duration: 500 } + +} + diff --git a/Qt_Performance_Benchmark/main.qml b/Qt_Performance_Benchmark/main.qml index 0f050e2..2eaf97b 100644 --- a/Qt_Performance_Benchmark/main.qml +++ b/Qt_Performance_Benchmark/main.qml @@ -3,66 +3,50 @@ import QtQuick.Window 2.12 import QtQuick.Controls 2.3 import be.mindgoo.tools 0.1 - Window { id: rootwin - width: 640 - height: 480 + width: 1920 + height: 1080 visible: true - title: qsTr("Hello World") - - Rectangle { - x: 20 - y: 20 - width: 100; height: 100 - color: "forestgreen" - - //NumberAnimation on x { id: ani; loops: Animation.Infinite; to: 250; duration: 1000 } - - NumberAnimation on x { id: ani; loops: Animation.Infinite; from: 0; to: 100; duration: 500 } - } - - - Rectangle { - x: 20 - y: 148 - width: 100; height: 100 - color: "blue" - - //NumberAnimation on x { id: ani; loops: Animation.Infinite; to: 250; duration: 1000 } - - NumberAnimation on x { id: ani2; loops: Animation.Infinite; from: 0; to: 1000; duration: 5000 } - } - - - - function onChecked(checked) { - - if (checked) { - ani.resume() - } else { - ani.pause() - } - } - - CheckBox { - id: checkBox - x: 41 - y: 279 - state: active - text: qsTr("Check Box") - onClicked: rootwin.onChecked(checked) - } + property var elements: 0 FrequencyMonitor { id: monitor refreshPeriod: 500 } - Text { - text: monitor.fps - } + function doSomething(){ + rootwin.elements++ + var component = Qt.createComponent("Rect.qml"); + var rect = component.createObject(rootwin,{"x":0,"y":0}); + if(rect !== null ) { + rect.name = "Test"; + rect.x = Math.floor(Math.random() * 100 ); + rect.y = Math.floor(Math.random() * 100 ); + } + } + Button{ + id: doBtn + text: "do" + x: 20 + y: 1000 + onClicked: rootwin.doSomething() + } + + Text { + id: fpsCounter + x: 200 + y: 1000 + text: "FPS: " + monitor.fps + } + + Text { + id: elementsCounter + x: 300 + y: 1000 + text: "Elements: " + rootwin.elements + } } /*##^## diff --git a/Qt_Performance_Benchmark/qml.qrc b/Qt_Performance_Benchmark/qml.qrc index 5f6483a..9ddd4f2 100644 --- a/Qt_Performance_Benchmark/qml.qrc +++ b/Qt_Performance_Benchmark/qml.qrc @@ -1,5 +1,6 @@ main.qml + Rect.qml