From b141f798d57310c60c59597aa9232f6884309d0a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 6 Jun 2015 15:25:26 +0200 Subject: Improve tst_objectcount Add support for VERBOSE=1 to get detailed object list, and improve the warmup by importing both controls and loading an image to avoid plugin loaders and image format plugins showing up in the numbers. Change-Id: I26cfdc6d71fe36b45b706164f696bbb7f055f078 Reviewed-by: J-P Nurmi --- tests/benchmarks/objectcount/tst_objectcount.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tests/benchmarks/objectcount/tst_objectcount.cpp') diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index d8493730..8caea23d 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -38,6 +38,8 @@ #include #include +static int qt_verbose = qgetenv("VERBOSE").toInt() != 0; + Q_GLOBAL_STATIC(QObjectList, qt_qobjects) extern "C" Q_DECL_EXPORT void qt_addQObject(QObject *object) @@ -72,7 +74,7 @@ void tst_ObjectCount::init() // warmup QQmlComponent component(&engine); - component.setData("import QtQuick 2.0; Item { Accessible.role: Accessible.Button }", QUrl()); + component.setData("import QtQuick 2.0; import QtQuick.Controls 1.3; import QtQuick.Controls 2.0; Image { Accessible.role: Accessible.Button; source: 'qrc:/qt-logo.png' }", QUrl()); delete component.create(); } @@ -82,6 +84,15 @@ void tst_ObjectCount::cleanup() qtHookData[QHooks::RemoveQObject] = 0; } +static void printItems(const QString &prefix, const QList &items) +{ + qInfo() << prefix << "QQuickItems:" << items.count() << "(total of QObjects:" << qt_qobjects->count() << ")"; + if (qt_verbose) { + foreach (QObject *object, *qt_qobjects) + qInfo() << "\t" << object; + } +} + void tst_ObjectCount::testCount() { QFETCH(QByteArray, v1); @@ -101,8 +112,7 @@ void tst_ObjectCount::testCount() if (item) items += item; } - - qInfo() << "V1: QQuickItems:" << items.count() << "(total of QObjects:" << qt_qobjects->count() << ")"; + printItems("V1", items); } qt_qobjects->clear(); @@ -119,8 +129,7 @@ void tst_ObjectCount::testCount() if (item) items += item; } - - qInfo() << "V2: QQuickItems:" << items.count() << "(total of QObjects:" << qt_qobjects->count() << ")"; + printItems("V2", items); } } -- cgit v1.2.3