Skip to content

Commit 6df1549

Browse files
authored
Add benchmark task and performance chart for viewer (#2961)
1 parent 01f7efb commit 6df1549

25 files changed

+1086
-3
lines changed
Lines changed: 3 additions & 0 deletions
Loading

viewer/images/performance-warn.png

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:b6289156df37db1e052e406fb5a5a587de10db8d91a3c4bda0543ea87382bcf8
3+
size 9292672

viewer/qml/Main.qml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import QtCore
33
import QtQuick
44
import QtQuick.Dialogs
55
import QtQuick.Controls
6+
import QtQuick.Layouts
67
import Qt.labs.settings
78
import Qt.labs.platform as Platform
89
import "components"
@@ -41,6 +42,12 @@ PAGWindow {
4142
property double lastX: 0
4243

4344
property double lastY: 0
45+
46+
property string benchmarkVersion: "0.0.0"
47+
48+
property string templateAvgRenderingTime: "30000"
49+
50+
property string templateFirstFrameRenderingTime: "60000"
4451
}
4552
MainForm {
4653
id: mainForm
@@ -251,6 +258,21 @@ PAGWindow {
251258
}
252259
}
253260

261+
PAGMessageBox {
262+
id: benchmarkCompleteMessageBox
263+
width: 500
264+
visible: false
265+
height: 130 + windowTitleBarHeight
266+
textSize: 12
267+
title: qsTr("Performance Benchmark Test")
268+
message: qsTr("Performance Benchmark Test Complete")
269+
}
270+
271+
BusyIndicator {
272+
id: benchmarkBusyIndicator
273+
running: false
274+
}
275+
254276
Connections {
255277
id: taskConnections
256278
onProgressChanged: function (progress) {
@@ -272,6 +294,25 @@ PAGWindow {
272294
}
273295
}
274296

297+
Connections {
298+
target: benchmarkModel
299+
300+
function onBenchmarkComplete(isAuto, templateAvgRenderingTime, templateFirstFrameRenderingTime) {
301+
settings.templateAvgRenderingTime = templateAvgRenderingTime;
302+
settings.templateFirstFrameRenderingTime = templateFirstFrameRenderingTime;
303+
304+
benchmarkBusyIndicator.visible = false;
305+
benchmarkBusyIndicator.running = false;
306+
307+
if (isAuto) {
308+
settings.benchmarkVersion = Qt.application.version;
309+
} else {
310+
benchmarkCompleteMessageBox.visible = true;
311+
benchmarkCompleteMessageBox.raise();
312+
}
313+
}
314+
}
315+
275316
Component.onCompleted: {
276317
viewWindow.title = "PAGViewer";
277318

@@ -498,6 +539,12 @@ PAGWindow {
498539
task.start();
499540
}
500541
break;
542+
case "performance-benchmark":
543+
mainForm.pagView.isPlaying = false;
544+
benchmarkBusyIndicator.visible = true;
545+
benchmarkBusyIndicator.running = true;
546+
benchmarkModel.startBenchmarkOnTemplate(false);
547+
break;
501548
default:
502549
console.log(`Undefined command: [${command}]`);
503550
break;

viewer/qml/Menu.qml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ Item {
5555
root.command("performance-profile");
5656
}
5757
}
58+
Action {
59+
text: qsTr("Performance Benchmark Test")
60+
enabled: root.hasPAGFile
61+
onTriggered: {
62+
root.command("performance-benchmark");
63+
}
64+
}
5865
PAGMenu {
5966
menuWidth: windowsMenuBar.menuWidth
6067
title: qsTr("Export")
@@ -236,6 +243,13 @@ Item {
236243
root.command("performance-profile");
237244
}
238245
}
246+
Platform.MenuItem {
247+
text: qsTr("Performance Benchmark Test")
248+
enabled: root.hasPAGFile
249+
onTriggered: {
250+
root.command("performance-benchmark");
251+
}
252+
}
239253
Platform.Menu {
240254
title: qsTr("Export")
241255
Platform.MenuItem {
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
4+
Popup {
5+
id: popup
6+
width: 200
7+
height: 200
8+
visible: false
9+
modal: true
10+
focus: true
11+
closePolicy: Popup.OnEscape
12+
13+
Overlay.modal: Rectangle {
14+
color: "transparent"
15+
}
16+
17+
property var warnMessage: ""
18+
19+
property var tipMessageList: []
20+
21+
property bool toTop: false
22+
property bool toLeft: true
23+
property bool toRight: false
24+
25+
background: borderImage
26+
27+
BorderImage {
28+
id: borderImage
29+
anchors.fill: parent
30+
source: toTop ? "qrc:/images/top-transparent-background.png" : toLeft ? "qrc:/images/left-transparent-background.png" : "qrc:/images/right-transparent-background.png"
31+
border.top: toTop ? 50 : 120
32+
border.bottom: 20
33+
border.left: toTop ? 120 : toLeft ? 50 : 20
34+
border.right: toRight ? 50 : 20
35+
36+
Column {
37+
width: parent.width
38+
height: parent.height
39+
spacing: 10
40+
41+
Item {
42+
width: 1
43+
height: toTop ? 10 : 2
44+
}
45+
46+
Text {
47+
id: warnText
48+
anchors.left: parent.left
49+
anchors.leftMargin: 16
50+
anchors.right: parent.right
51+
anchors.rightMargin: 12
52+
horizontalAlignment: Text.AlignLeft
53+
verticalAlignment: Text.AlignVCenter
54+
color: "#FFFFFF"
55+
text: warnMessage
56+
wrapMode: Text.Wrap
57+
font.pixelSize: 12
58+
}
59+
60+
Repeater {
61+
model: tipMessageList
62+
delegate: Rectangle {
63+
width: parent.width - 20
64+
height: childrenRect.height + 20
65+
anchors.left: parent.left
66+
anchors.leftMargin: toLeft ? 12 : 8
67+
anchors.right: parent.right
68+
anchors.rightMargin: toRight ? 12 : 8
69+
radius: 2
70+
color: "#2F2E39"
71+
implicitWidth: 100
72+
implicitHeight: modelData.paintedHeight + 9 * 2
73+
border.color: "#2F2E39"
74+
border.width: 1
75+
76+
Text {
77+
width: parent.width - 16
78+
text: modelData
79+
font.pixelSize: 12
80+
anchors.top: parent.top
81+
anchors.topMargin: 10
82+
anchors.bottomMargin: 10
83+
anchors.left: parent.left
84+
anchors.leftMargin: 8
85+
anchors.right: parent.right
86+
anchors.rightMargin: 8
87+
horizontalAlignment: Text.AlignLeft
88+
verticalAlignment: Text.AlignVCenter
89+
color: "#FFFFFF"
90+
wrapMode: Text.Wrap
91+
}
92+
}
93+
}
94+
}
95+
}
96+
97+
98+
99+
function addTip(newString) {
100+
tipMessageList.push(newString)
101+
tipMessageList = tipMessageList.slice()
102+
}
103+
104+
function clearAllTips() {
105+
tipMessageList = []
106+
}
107+
108+
function setToTop() {
109+
toTop = true;
110+
toLeft = false;
111+
toRight = false;
112+
}
113+
114+
function setToLeft() {
115+
toTop = false;
116+
toLeft = true;
117+
toRight = false;
118+
}
119+
120+
function setToRight() {
121+
toTop = false;
122+
toLeft = false;
123+
toRight = true;
124+
}
125+
}

0 commit comments

Comments
 (0)