diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/startup/gallery.qrc | 1 | ||||
-rw-r--r-- | tests/benchmarks/startup/startup_bench.cpp | 37 | ||||
-rw-r--r-- | tests/benchmarks/startup/timer.qml | 7 |
3 files changed, 19 insertions, 26 deletions
diff --git a/tests/benchmarks/startup/gallery.qrc b/tests/benchmarks/startup/gallery.qrc index 2cabf889..1a84303a 100644 --- a/tests/benchmarks/startup/gallery.qrc +++ b/tests/benchmarks/startup/gallery.qrc @@ -1,6 +1,5 @@ <RCC> <qresource prefix="/"> - <file>timer.qml</file> <file alias="main.qml">../../../examples/quickcontrols/controls/gallery/main.qml</file> <file alias="qml/ButtonPage.qml">../../../examples/quickcontrols/controls/gallery/qml/ButtonPage.qml</file> <file alias="qml/InputPage.qml">../../../examples/quickcontrols/controls/gallery/qml/InputPage.qml</file> 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); diff --git a/tests/benchmarks/startup/timer.qml b/tests/benchmarks/startup/timer.qml deleted file mode 100644 index a0e9f1c1..00000000 --- a/tests/benchmarks/startup/timer.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.2 - -Timer { - running: true - interval: 0 - onTriggered: Qt.quit(); -} |