summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-10-29 17:42:45 +0100
committerErik Verbruggen <erik.verbruggen@qt.io>2018-10-31 14:36:27 +0000
commit0489c0a88a293696592c5892383698a015ae68c7 (patch)
treeda95c779939217aa736f03e74392941821e83cce
parent5db6659d65062353cfa6425f7790ea34f1b4a3f4 (diff)
downloadqtquickcontrols-0489c0a88a293696592c5892383698a015ae68c7.tar.gz
Improve startup benchmark
Don't measure the time it takes to destruct the QQmlEngine, as that may be heavy work due to the last sweep of the garbage collector heap and deleting all engine-owned QObjects. Change-Id: Ibdd3d92e306d0418ee7080077b8894950878ec43 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r--tests/benchmarks/startup/startup_bench.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/benchmarks/startup/startup_bench.cpp b/tests/benchmarks/startup/startup_bench.cpp
index cdc754ec..9e734cf8 100644
--- a/tests/benchmarks/startup/startup_bench.cpp
+++ b/tests/benchmarks/startup/startup_bench.cpp
@@ -54,25 +54,21 @@
#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 +79,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,
QCoreApplication::instance(), &QCoreApplication::quit);
engine.load(QUrl("qrc:/timer.qml"));
if (engine.rootObjects().size() != 2)
return -1;
- return app.exec();
+ if (app.exec() != 0)
+ return -1;
+ return timer.elapsed();
};
return runBenchmark(startup);