summaryrefslogtreecommitdiff
path: root/tests/benchmarks/startup/startup_bench.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/startup/startup_bench.cpp')
-rw-r--r--tests/benchmarks/startup/startup_bench.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/tests/benchmarks/startup/startup_bench.cpp b/tests/benchmarks/startup/startup_bench.cpp
index cdc754ec..ea510e8c 100644
--- a/tests/benchmarks/startup/startup_bench.cpp
+++ b/tests/benchmarks/startup/startup_bench.cpp
@@ -50,29 +50,26 @@
#include "qtquickcontrolsapplication.h"
#include <QtQml/QQmlApplicationEngine>
+#include <QQuickWindow>
#include <QtCore/QElapsedTimer>
#include <functional>
#include <stdio.h>
-int runBenchmark(std::function<int()> f) {
+int runBenchmark(std::function<qint64()> f) {
{
- QElapsedTimer t;
- t.start();
- int r = f();
- if (r == 0)
- printf("%d,", static_cast<int>(t.elapsed()));
+ auto r = f();
+ if (r >= 0)
+ printf("%d,", static_cast<int>(r));
else
- return r;
+ return -1;
}
{
- QElapsedTimer t;
- t.start();
- int r = f();
- if (r == 0)
- printf("%d\n", static_cast<int>(t.elapsed()));
+ auto r = f();
+ if (r >= 0)
+ printf("%d\n", static_cast<int>(r));
else
- return r;
+ return -1;
}
return 0;
@@ -83,14 +80,18 @@ int main(int argc, char *argv[])
{
QtQuickControlsApplication app(argc, argv);
- auto startup = [&app]() {
+ auto startup = [&app]() -> qint64 {
+ QElapsedTimer timer;
+ timer.start();
QQmlApplicationEngine engine(QUrl("qrc:/main.qml"));
- QObject::connect(&engine, &QQmlApplicationEngine::quit,
+ if (engine.rootObjects().size() != 1)
+ return -1;
+ QQuickWindow *window = qobject_cast<QQuickWindow*>(engine.rootObjects().first());
+ QObject::connect(window, &QQuickWindow::frameSwapped,
QCoreApplication::instance(), &QCoreApplication::quit);
- engine.load(QUrl("qrc:/timer.qml"));
- if (engine.rootObjects().size() != 2)
+ if (app.exec() != 0)
return -1;
- return app.exec();
+ return timer.elapsed();
};
return runBenchmark(startup);