Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
QML_Benchmark
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Daniel Smith
QML_Benchmark
Commits
7c47e1ce
Commit
7c47e1ce
authored
Dec 12, 2018
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic QML and benchmark framework to measure frame times.
parent
f7514ea4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
175 additions
and
77 deletions
+175
-77
Heavy_QML_example.pro
Heavy_QML_example.pro
+5
-1
Heavy_QML_example.pro.user
Heavy_QML_example.pro.user
+26
-43
benchmark.cpp
benchmark.cpp
+53
-0
benchmark.h
benchmark.h
+31
-0
main.cpp
main.cpp
+40
-6
main.qml
main.qml
+12
-27
qml.qrc
qml.qrc
+1
-0
timer.qml
timer.qml
+7
-0
No files found.
Heavy_QML_example.pro
View file @
7c47e1ce
...
...
@@ -13,7 +13,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
#
DEFINES
+=
QT_DISABLE_DEPRECATED_BEFORE
=
0
x060000
#
disables
all
the
APIs
deprecated
before
Qt
6.0
.
0
SOURCES
+=
\
main
.
cpp
main
.
cpp
\
benchmark
.
cpp
RESOURCES
+=
qml
.
qrc
...
...
@@ -27,3 +28,6 @@ QML_DESIGNER_IMPORT_PATH =
qnx
:
target
.
path
=
/
tmp
/
$$
{
TARGET
}
/
bin
else
:
unix
:
!
android
:
target
.
path
=
/
opt
/
$$
{
TARGET
}
/
bin
!
isEmpty
(
target
.
path
)
:
INSTALLS
+=
target
HEADERS
+=
\
benchmark
.
h
Heavy_QML_example.pro.user
View file @
7c47e1ce
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.
7.1, 2018-12-12T11:59:36
. -->
<!-- Written by QtCreator 4.
8.0, 2018-12-12T16:24:04
. -->
<qtcreator>
<data>
<variable>
EnvironmentId
</variable>
...
...
@@ -54,7 +54,10 @@
</data>
<data>
<variable>
ProjectExplorer.Project.PluginSettings
</variable>
<valuemap
type=
"QVariantMap"
/>
<valuemap
type=
"QVariantMap"
>
<valuelist
type=
"QVariantList"
key=
"ClangCodeModel.CustomCommandLineKey"
/>
<value
type=
"bool"
key=
"ClangCodeModel.UseGlobalConfig"
>
true
</value>
</valuemap>
</data>
<data>
<variable>
ProjectExplorer.Project.Target.0
</variable>
...
...
@@ -84,13 +87,11 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
>
<value
type=
"QString"
>
-w
</value>
<value
type=
"QString"
>
-r
</value>
</valuelist>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.BuildTargets"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
false
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.OverrideMakeflags"
>
false
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
2
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Build
</value>
...
...
@@ -103,13 +104,11 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
>
<value
type=
"QString"
>
-w
</value>
<value
type=
"QString"
>
-r
</value>
</valuelist>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.BuildTargets"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
true
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
>
clean
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.OverrideMakeflags"
>
false
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
1
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Clean
</value>
...
...
@@ -144,13 +143,11 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
>
<value
type=
"QString"
>
-w
</value>
<value
type=
"QString"
>
-r
</value>
</valuelist>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.BuildTargets"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
false
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.OverrideMakeflags"
>
false
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
2
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Build
</value>
...
...
@@ -163,13 +160,11 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
>
<value
type=
"QString"
>
-w
</value>
<value
type=
"QString"
>
-r
</value>
</valuelist>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.BuildTargets"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
true
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
>
clean
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.OverrideMakeflags"
>
false
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
1
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Clean
</value>
...
...
@@ -204,13 +199,11 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
>
<value
type=
"QString"
>
-w
</value>
<value
type=
"QString"
>
-r
</value>
</valuelist>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.BuildTargets"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
false
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.OverrideMakeflags"
>
false
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
2
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Build
</value>
...
...
@@ -223,13 +216,11 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Make
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.MakeStep
</value>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"
>
<value
type=
"QString"
>
-w
</value>
<value
type=
"QString"
>
-r
</value>
</valuelist>
<valuelist
type=
"QVariantList"
key=
"Qt4ProjectManager.MakeStep.BuildTargets"
/>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.Clean"
>
true
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeArguments"
>
clean
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.MakeStep.MakeCommand"
></value>
<value
type=
"bool"
key=
"Qt4ProjectManager.MakeStep.OverrideMakeflags"
>
false
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.BuildStepList.StepsCount"
>
1
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Clean
</value>
...
...
@@ -261,15 +252,6 @@
<value
type=
"int"
key=
"ProjectExplorer.Target.DeployConfigurationCount"
>
1
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.PluginSettings"
/>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.RunConfiguration.0"
>
<value
type=
"QString"
key=
"Analyzer.Perf.CallgraphMode"
>
dwarf
</value>
<valuelist
type=
"QVariantList"
key=
"Analyzer.Perf.Events"
>
<value
type=
"QString"
>
cpu-cycles
</value>
</valuelist>
<valuelist
type=
"QVariantList"
key=
"Analyzer.Perf.ExtraArguments"
/>
<value
type=
"int"
key=
"Analyzer.Perf.Frequency"
>
250
</value>
<value
type=
"QString"
key=
"Analyzer.Perf.SampleMode"
>
-F
</value>
<value
type=
"bool"
key=
"Analyzer.Perf.Settings.UseGlobalSettings"
>
true
</value>
<value
type=
"int"
key=
"Analyzer.Perf.StackSize"
>
4096
</value>
<value
type=
"bool"
key=
"Analyzer.QmlProfiler.AggregateTraces"
>
false
</value>
<value
type=
"bool"
key=
"Analyzer.QmlProfiler.FlushEnabled"
>
false
</value>
<value
type=
"uint"
key=
"Analyzer.QmlProfiler.FlushInterval"
>
1000
</value>
...
...
@@ -311,19 +293,20 @@
</valuelist>
<value
type=
"int"
key=
"PE.EnvironmentAspect.Base"
>
2
</value>
<valuelist
type=
"QVariantList"
key=
"PE.EnvironmentAspect.Changes"
/>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.Arguments"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.Executable"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory.default"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Custom Executable
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Heavy_QML_example
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
ProjectExplorer.CustomExecutableRunConfiguration
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.Qt4RunConfiguration:/home/dan/projects/Heavy_QML_example/Heavy_QML_example.pro
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.ProFile"
>
Heavy_QML_example.pro
</value>
<value
type=
"QString"
key=
"RunConfiguration.Arguments"
></value>
<value
type=
"uint"
key=
"RunConfiguration.QmlDebugServerPort"
>
3768
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebugger"
>
false
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebuggerAuto"
>
true
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseLibrarySearchPath"
>
true
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseMultiProcess"
>
false
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseQmlDebugger"
>
false
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseQmlDebuggerAuto"
>
true
</value>
<value
type=
"QString"
key=
"RunConfiguration.WorkingDirectory"
></value>
<value
type=
"QString"
key=
"RunConfiguration.WorkingDirectory.default"
>
/home/dan/projects/build-Heavy_QML_example-Desktop_Qt_5_12_0_GCC_64bit4-Debug
</value>
</valuemap>
<value
type=
"int"
key=
"ProjectExplorer.Target.RunConfigurationCount"
>
1
</value>
</valuemap>
...
...
@@ -334,10 +317,10 @@
</data>
<data>
<variable>
ProjectExplorer.Project.Updater.FileVersion
</variable>
<value
type=
"int"
>
18
</value>
<value
type=
"int"
>
20
</value>
</data>
<data>
<variable>
Version
</variable>
<value
type=
"int"
>
18
</value>
<value
type=
"int"
>
20
</value>
</data>
</qtcreator>
benchmark.cpp
0 → 100644
View file @
7c47e1ce
#include <QObject>
#include <benchmark.h>
#include <QtDebug>
#include <QString>
#include <QElapsedTimer>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include <QGuiApplication>
void
Benchmark
::
startTimer
(){
}
void
Benchmark
::
countFrame
(){
qint64
frametime
=
timer
.
restart
();
int
thisframe
=
static_cast
<
int
>
(
frametime
);
try
{
frametimes
[
frame
]
=
thisframe
;
}
catch
(
int
e
){
printf
(
"frame."
);
//No need to handle this. We probably just rendered extra frames before finished() completed.
}
printf
(
"frame %d: %d ms
\n
"
,
frame
,
thisframe
);
frame
+=
1
;
if
(
frame
>=
maxframes
){
this
->
finished
();
}
}
void
Benchmark
::
measureFrame
(
qint64
value
){
printf
(
"%d,"
,
static_cast
<
int
>
(
value
));
}
void
Benchmark
::
finished
(){
QCoreApplication
::
quit
();
}
int
Benchmark
::
runBenchmark
(
QGuiApplication
&
app
){
this
->
timer
.
start
();
QQmlApplicationEngine
engine
(
QUrl
(
"qrc:/main.qml"
));
if
(
engine
.
rootObjects
().
size
()
!=
1
)
return
-
1
;
QQuickWindow
*
window
=
qobject_cast
<
QQuickWindow
*>
(
engine
.
rootObjects
().
first
());
//Finish timing after the first frame is ready.
QObject
::
connect
(
window
,
&
QQuickWindow
::
frameSwapped
,
this
,
&
Benchmark
::
countFrame
);
//QCoreApplication::instance(), &QCoreApplication::quit);
if
(
app
.
exec
()
!=
0
)
return
-
1
;
//return timer.elapsed(); //change to print averages.
//return runBenchmark(startup);
}
benchmark.h
0 → 100644
View file @
7c47e1ce
#ifndef BENCHMARK_H
#define BENCHMARK_H
#include <QObject>
#include <QGuiApplication>
#include <QElapsedTimer>
class
Benchmark
:
public
QObject
{
public:
int
runBenchmark
(
QGuiApplication
&
);
public
slots
:
void
countFrame
();
void
countMemory
(
int
value
);
private:
QElapsedTimer
timer
;
int
frame
=
0
;
int
lastframetotal
;
static
const
int
maxframes
=
120
;
int
frametimes
[
maxframes
];
void
finished
();
void
startTimer
();
void
measureFrame
(
qint64
);
};
#endif // BENCHMARK_H
main.cpp
View file @
7c47e1ce
#include <QGuiApplication>
#include <QQuickWindow>
#include <QQmlApplicationEngine>
#include <QtCore/QElapsedTimer>
#include <benchmark.h>
int
runBenchmark
(
std
::
function
<
qint64
()
>
f
)
{
{
printf
(
"Startup times (ms): [1st run, 2nd run]
\n
"
);
auto
r
=
f
();
if
(
r
>=
0
)
printf
(
"%d,"
,
static_cast
<
int
>
(
r
));
else
return
-
1
;
}
{
auto
r
=
f
();
if
(
r
>=
0
)
printf
(
"%d
\n
"
,
static_cast
<
int
>
(
r
));
else
return
-
1
;
}
return
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -14,10 +38,20 @@ int main(int argc, char *argv[])
QGuiApplication
app
(
argc
,
argv
);
QQmlApplicationEngine
engine
;
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:/main.qml"
)));
if
(
engine
.
rootObjects
().
isEmpty
())
return
-
1
;
return
app
.
exec
();
Benchmark
benchmark
;
/*
auto startup = [&app](){
QQmlApplicationEngine engine(QUrl("qrc:/main.qml"));
if (engine.rootObjects().size() != 1)
return -1;
QQuickWindow *window = qobject_cast<QQuickWindow*>(engine.rootObjects().first());
QObject::connect(window, &QQuickWindow::frameSwapped,
&benchmark, &Benchmark::countFrame);
//QCoreApplication::instance(), &QCoreApplication::quit);
if (app.exec() != 0)
return -1;
};
*/
//return runBenchmark(startup);
return
benchmark
.
runBenchmark
(
app
);
}
main.qml
View file @
7c47e1ce
import
QtQuick
2.6
import
QtQuick
.
Window
2.2
import
QtQuick
.
Enterprise
.
VirtualKeyboard
2.0
Window
{
id
:
window
...
...
@@ -9,32 +9,17 @@ Window {
height
:
480
title
:
qsTr
(
"
Hello World
"
)
InputPanel
{
id
:
inputPanel
z
:
99
x
:
0
y
:
window
.
height
width
:
window
.
width
states
:
State
{
name
:
"
visible
"
when
:
inputPanel
.
active
PropertyChanges
{
target
:
inputPanel
y
:
window
.
height
-
inputPanel
.
height
}
}
transitions
:
Transition
{
from
:
""
to
:
"
visible
"
reversible
:
true
ParallelAnimation
{
NumberAnimation
{
properties
:
"
y
"
duration
:
250
easing.type
:
Easing
.
InOutQuad
}
}
Rectangle
{
id
:
xmovingBox
width
:
50
height
:
50
color
:
"
lightsteelblue
"
XAnimator
{
target
:
xmovingBox
;
from
:
590
;
to
:
0
;
duration
:
30000
running
:
true
}
}
}
qml.qrc
View file @
7c47e1ce
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>timer.qml</file>
</qresource>
</RCC>
timer.qml
0 → 100644
View file @
7c47e1ce
import
QtQuick
2.2
Timer
{
running
:
true
interval
:
0
onTriggered
:
Qt
.
quit
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment