summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/benchmarks/startup/gallery.qrc13
-rw-r--r--tests/benchmarks/startup/startup.pro13
-rw-r--r--tests/benchmarks/startup/startup_bench.cpp82
-rw-r--r--tests/benchmarks/startup/timer.qml7
4 files changed, 115 insertions, 0 deletions
diff --git a/tests/benchmarks/startup/gallery.qrc b/tests/benchmarks/startup/gallery.qrc
new file mode 100644
index 00000000..2cabf889
--- /dev/null
+++ b/tests/benchmarks/startup/gallery.qrc
@@ -0,0 +1,13 @@
+<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>
+ <file alias="qml/ProgressPage.qml">../../../examples/quickcontrols/controls/gallery/qml/ProgressPage.qml</file>
+ <file alias="qml/UI.js">../../../examples/quickcontrols/controls/gallery/qml/UI.js</file>
+ <file alias="+android/UI.js">../../../examples/quickcontrols/controls/gallery/qml/+android/UI.js</file>
+ <file alias="+ios/UI.js">../../../examples/quickcontrols/controls/gallery/qml/+ios/UI.js</file>
+ <file alias="+osx/UI.js">../../../examples/quickcontrols/controls/gallery/qml/+osx/UI.js</file>
+ </qresource>
+</RCC>
diff --git a/tests/benchmarks/startup/startup.pro b/tests/benchmarks/startup/startup.pro
new file mode 100644
index 00000000..e8343181
--- /dev/null
+++ b/tests/benchmarks/startup/startup.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = tst_startup
+
+CONFIG += console c++11
+macos:CONFIG -= app_bundle
+
+SOURCES += \
+ startup_bench.cpp
+
+RESOURCES += \
+ gallery.qrc
+
+include(../../../examples/quickcontrols/controls/shared/shared.pri)
diff --git a/tests/benchmarks/startup/startup_bench.cpp b/tests/benchmarks/startup/startup_bench.cpp
new file mode 100644
index 00000000..374012d5
--- /dev/null
+++ b/tests/benchmarks/startup/startup_bench.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtquickcontrolsapplication.h"
+#include <QtQml/QQmlApplicationEngine>
+#include <QtCore/QElapsedTimer>
+#include <functional>
+
+int runBenchmark(std::function<int()> f) {
+ {
+ QElapsedTimer t;
+ t.start();
+ int r = f();
+ if (r == 0)
+ printf("%d,", static_cast<int>(t.elapsed()));
+ else
+ return r;
+ }
+
+ {
+ QElapsedTimer t;
+ t.start();
+ int r = f();
+ if (r == 0)
+ printf("%d\n", static_cast<int>(t.elapsed()));
+ else
+ return r;
+ }
+
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ QtQuickControlsApplication app(argc, argv);
+
+ auto startup = [&app]() -> int {
+ QQmlApplicationEngine engine(QUrl("qrc:/main.qml"));
+ QObject::connect(&engine, &QQmlApplicationEngine::quit,
+ QCoreApplication::instance(), &QCoreApplication::quit);
+ engine.load(QUrl("qrc:/timer.qml"));
+ if (engine.rootObjects().size() != 2)
+ return -1;
+ return app.exec();
+ };
+
+ return runBenchmark(startup);
+}
diff --git a/tests/benchmarks/startup/timer.qml b/tests/benchmarks/startup/timer.qml
new file mode 100644
index 00000000..a0e9f1c1
--- /dev/null
+++ b/tests/benchmarks/startup/timer.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.2
+
+Timer {
+ running: true
+ interval: 0
+ onTriggered: Qt.quit();
+}