From 6e4f3fcef91b19b2f536a27afc975a056c29375f Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 30 Jun 2014 14:32:28 +0200 Subject: [PATCH 1/6] Allow setting Qt Creator source and build dirs through qmake variables So they can be set through .qmake.conf in a subdirs project above it. Change-Id: I919e637fb7ed8a7f341982f0a9f06953e0131a2a Reviewed-by: Ulf Hermann --- qtcreatorplugin.pri | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qtcreatorplugin.pri b/qtcreatorplugin.pri index 6579467a0d7..190dbed1c3b 100644 --- a/qtcreatorplugin.pri +++ b/qtcreatorplugin.pri @@ -1,5 +1,5 @@ -IDE_SOURCE_TREE=$$(QTC_SOURCE) -IDE_BUILD_TREE=$$(QTC_BUILD) +isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE=$$(QTC_SOURCE) +isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE=$$(QTC_BUILD) isEmpty(IDE_SOURCE_TREE):error(Set QTC_SOURCE environment variable) isEmpty(IDE_BUILD_TREE):error(Set QTC_BUILD environment variable) From da597356a1209a60fb2237f71bd4cc7b6165701b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 3 Jun 2014 19:06:34 +0200 Subject: [PATCH 2/6] Show scene graph events in correct thread for non-threaded render loop If no polishAndSync event is ever seen we can be sure the application is doing non-threaded rendering. In that case all other events belong to the GUI thread rather than the render thread. Change-Id: Ib5d0cbcdc7c45bff6303a1b4bfb1f5333830c7f7 Reviewed-by: Kai Koehne --- .../scenegraphtimelinemodel.cpp | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp index 3f457476f73..59267d2c72a 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp @@ -46,8 +46,8 @@ enum SceneGraphEventType { }; enum SceneGraphCategoryType { - SceneGraphRenderThread, SceneGraphGUIThread, + SceneGraphRenderThread, MaximumSceneGraphCategoryType }; @@ -59,6 +59,7 @@ class SceneGraphTimelineModel::SceneGraphTimelineModelPrivate : public: void addVP(QVariantList &l, QString label, qint64 time) const; private: + bool seenPolishAndSync; Q_DECLARE_PUBLIC(SceneGraphTimelineModel) }; @@ -67,25 +68,28 @@ SceneGraphTimelineModel::SceneGraphTimelineModel(QObject *parent) QLatin1String("SceneGraphTimeLineModel"), tr("Scene Graph"), QmlDebug::SceneGraphFrame, QmlDebug::MaximumRangeType, parent) { + Q_D(SceneGraphTimelineModel); + d->seenPolishAndSync = false; } int SceneGraphTimelineModel::rowCount() const { + Q_D(const SceneGraphTimelineModel); if (isEmpty()) return 1; - return 3; + return d->seenPolishAndSync ? 3 : 2; } int SceneGraphTimelineModel::getEventRow(int index) const { Q_D(const SceneGraphTimelineModel); - return d->range(index).sgEventType + 1; + return d->seenPolishAndSync ? d->range(index).sgEventType + 1 : 1; } int SceneGraphTimelineModel::getEventId(int index) const { Q_D(const SceneGraphTimelineModel); - return d->range(index).sgEventType; + return d->seenPolishAndSync ? d->range(index).sgEventType : SceneGraphGUIThread; } QColor SceneGraphTimelineModel::getColor(int index) const @@ -121,13 +125,22 @@ const QVariantList SceneGraphTimelineModel::getLabels() const Q_D(const SceneGraphTimelineModel); QVariantList result; - if (d->expanded && !isEmpty()) { - for (int i = 0; i < MaximumSceneGraphCategoryType; i++) { - QVariantMap element; + static QVariant renderThreadLabel(labelForSGType(SceneGraphRenderThread)); + static QVariant guiThreadLabel(labelForSGType(SceneGraphGUIThread)); - element.insert(QLatin1String("displayName"), QVariant(labelForSGType(i))); - element.insert(QLatin1String("description"), QVariant(labelForSGType(i))); - element.insert(QLatin1String("id"), QVariant(i)); + if (d->expanded && !isEmpty()) { + { + QVariantMap element; + element.insert(QLatin1String("displayName"), guiThreadLabel); + element.insert(QLatin1String("description"), guiThreadLabel); + element.insert(QLatin1String("id"), SceneGraphGUIThread); + result << element; + } + if (d->seenPolishAndSync) { + QVariantMap element; + element.insert(QLatin1String("displayName"), renderThreadLabel); + element.insert(QLatin1String("description"), renderThreadLabel); + element.insert(QLatin1String("id"), SceneGraphRenderThread); result << element; } } @@ -155,7 +168,8 @@ const QVariantList SceneGraphTimelineModel::getEventDetails(int index) const { QVariantMap res; - res.insert(QLatin1String("title"), QVariant(labelForSGType(ev->sgEventType))); + res.insert(QLatin1String("title"), QVariant(labelForSGType( + d->seenPolishAndSync ? ev->sgEventType : SceneGraphGUIThread))); result << res; } @@ -252,6 +266,7 @@ void SceneGraphTimelineModel::loadData() break; } case SceneGraphPolishAndSync: { + d->seenPolishAndSync = true; // GUI thread SceneGraphEvent newEvent; newEvent.sgEventType = SceneGraphGUIThread; @@ -294,6 +309,7 @@ void SceneGraphTimelineModel::clear() { Q_D(SceneGraphTimelineModel); d->clear(); + d->seenPolishAndSync = false; d->expanded = false; d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1); } From 7f0b2b40879ad83825f8d03ca771059c7b3bd152 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 23 Jun 2014 16:32:26 +0200 Subject: [PATCH 3/6] Remove redundant displayNames There is no point in showing a displayName that's the same as the description. Change-Id: Ie6ace79e622e31b87ff42d741e04103a920b36e4 Reviewed-by: Kai Koehne --- plugins/qmlprofilerextension/memoryusagemodel.cpp | 2 -- plugins/qmlprofilerextension/pixmapcachemodel.cpp | 3 --- plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp | 2 -- 3 files changed, 7 deletions(-) diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp index 44827157025..6b48d45c1e7 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.cpp +++ b/plugins/qmlprofilerextension/memoryusagemodel.cpp @@ -89,7 +89,6 @@ const QVariantList MemoryUsageModel::getLabels() const if (d->expanded && !isEmpty()) { { QVariantMap element; - element.insert(QLatin1String("displayName"), QVariant(tr("Memory Allocation"))); element.insert(QLatin1String("description"), QVariant(tr("Memory Allocation"))); element.insert(QLatin1String("id"), QVariant(QmlDebug::HeapPage)); @@ -98,7 +97,6 @@ const QVariantList MemoryUsageModel::getLabels() const { QVariantMap element; - element.insert(QLatin1String("displayName"), QVariant(tr("Memory Usage"))); element.insert(QLatin1String("description"), QVariant(tr("Memory Usage"))); element.insert(QLatin1String("id"), QVariant(QmlDebug::SmallItem)); diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index 11606256292..c66055aa0ca 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -153,7 +153,6 @@ const QVariantList PixmapCacheModel::getLabels() const { // Cache Size QVariantMap element; - element.insert(QLatin1String("displayName"), QVariant(QLatin1String("Cache Size"))); element.insert(QLatin1String("description"), QVariant(QLatin1String("Cache Size"))); element.insert(QLatin1String("id"), QVariant(0)); @@ -163,8 +162,6 @@ const QVariantList PixmapCacheModel::getLabels() const for (int i=0; i < d->pixmaps.count(); i++) { // Loading QVariantMap element; - element.insert(QLatin1String("displayName"), - QVariant(getFilenameOnly(d->pixmaps[i].url))); element.insert(QLatin1String("description"), QVariant(getFilenameOnly(d->pixmaps[i].url))); diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp index 59267d2c72a..a29ddfe1b3a 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp @@ -131,14 +131,12 @@ const QVariantList SceneGraphTimelineModel::getLabels() const if (d->expanded && !isEmpty()) { { QVariantMap element; - element.insert(QLatin1String("displayName"), guiThreadLabel); element.insert(QLatin1String("description"), guiThreadLabel); element.insert(QLatin1String("id"), SceneGraphGUIThread); result << element; } if (d->seenPolishAndSync) { QVariantMap element; - element.insert(QLatin1String("displayName"), renderThreadLabel); element.insert(QLatin1String("description"), renderThreadLabel); element.insert(QLatin1String("id"), SceneGraphRenderThread); result << element; From 7eca9fbc4205cc1e1c31c04674e9b9672f2b73ce Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 24 Jun 2014 11:53:19 +0200 Subject: [PATCH 4/6] Add scale to memory usage and pixmap cache models Change-Id: I69cb67a97b0bb3407f509db01ec2d4b9acd177db Reviewed-by: Kai Koehne --- plugins/qmlprofilerextension/memoryusagemodel.cpp | 9 ++++++++- plugins/qmlprofilerextension/memoryusagemodel.h | 1 + plugins/qmlprofilerextension/pixmapcachemodel.cpp | 12 +++++++++++- plugins/qmlprofilerextension/pixmapcachemodel.h | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp index 6b48d45c1e7..64a6aa44f85 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.cpp +++ b/plugins/qmlprofilerextension/memoryusagemodel.cpp @@ -54,6 +54,13 @@ int MemoryUsageModel::rowCount() const return isEmpty() ? 1 : 3; } +int MemoryUsageModel::rowMaxValue(int rowNumber) const +{ + Q_D(const MemoryUsageModel); + Q_UNUSED(rowNumber); + return d->maxSize; +} + int MemoryUsageModel::getEventRow(int index) const { Q_D(const MemoryUsageModel); @@ -78,7 +85,7 @@ QColor MemoryUsageModel::getColor(int index) const float MemoryUsageModel::getHeight(int index) const { Q_D(const MemoryUsageModel); - return qMin(1.0f, (float)d->range(index).size / (float)d->maxSize * 0.85f + 0.15f); + return qMin(1.0f, (float)d->range(index).size / (float)d->maxSize); } const QVariantList MemoryUsageModel::getLabels() const diff --git a/plugins/qmlprofilerextension/memoryusagemodel.h b/plugins/qmlprofilerextension/memoryusagemodel.h index ce7fdb8b746..c256b02590e 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.h +++ b/plugins/qmlprofilerextension/memoryusagemodel.h @@ -43,6 +43,7 @@ public: MemoryUsageModel(QObject *parent = 0); int rowCount() const; + int rowMaxValue(int rowNumber) const; int getEventRow(int index) const; int getEventId(int index) const; diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index c66055aa0ca..ec4da50f10f 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -103,6 +103,16 @@ int PixmapCacheModel::rowCount() const return d->collapsedRowCount; } +int PixmapCacheModel::rowMaxValue(int rowNumber) const +{ + Q_D(const PixmapCacheModel); + if (rowNumber == 1) { + return d->maxCacheSize; + } else { + return AbstractTimelineModel::rowMaxValue(rowNumber); + } +} + int PixmapCacheModel::getEventRow(int index) const { Q_D(const PixmapCacheModel); @@ -131,7 +141,7 @@ float PixmapCacheModel::getHeight(int index) const { Q_D(const PixmapCacheModel); if (d->range(index).pixmapEventType == PixmapCacheCountChanged) - return 0.15 + (float)d->range(index).cacheSize * 0.85 / (float)d->maxCacheSize; + return (float)d->range(index).cacheSize / (float)d->maxCacheSize; else return 1.0f; } diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h index 688be42a1ce..888a5f66ed1 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.h +++ b/plugins/qmlprofilerextension/pixmapcachemodel.h @@ -56,6 +56,7 @@ public: PixmapCacheModel(QObject *parent = 0); int rowCount() const; + int rowMaxValue(int rowNumber) const; int getEventRow(int index) const; Q_INVOKABLE int getEventId(int index) const; From 3a5340e1a8ed20402995a333c49ca7f9e592677d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 24 Jun 2014 11:53:47 +0200 Subject: [PATCH 5/6] Group memory usage events by their cause and add location information Change-Id: Id33fa51daffe97e9e60467942b92f0598a17c27d Reviewed-by: Kai Koehne --- .../qmlprofilerextension/memoryusagemodel.cpp | 109 ++++++++++++++---- .../qmlprofilerextension/memoryusagemodel.h | 3 + 2 files changed, 90 insertions(+), 22 deletions(-) diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp index 64a6aa44f85..8cf9a421584 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.cpp +++ b/plugins/qmlprofilerextension/memoryusagemodel.cpp @@ -22,7 +22,7 @@ #include "qmlprofiler/sortedtimelinemodel.h" #include "qmlprofiler/abstracttimelinemodel_p.h" -#include +#include namespace QmlProfilerExtension { namespace Internal { @@ -88,6 +88,28 @@ float MemoryUsageModel::getHeight(int index) const return qMin(1.0f, (float)d->range(index).size / (float)d->maxSize); } +const QVariantMap MemoryUsageModel::getEventLocation(int index) const +{ + static const QLatin1String file("file"); + static const QLatin1String line("line"); + static const QLatin1String column("column"); + + Q_D(const MemoryUsageModel); + QVariantMap result; + + int originType = d->range(index).originTypeIndex; + if (originType > -1) { + const QmlDebug::QmlEventLocation &location = + d->modelManager->qmlModel()->getEventTypes().at(originType).location; + + result.insert(file, location.filename); + result.insert(line, location.line); + result.insert(column, location.column); + } + + return result; +} + const QVariantList MemoryUsageModel::getLabels() const { Q_D(const MemoryUsageModel); @@ -149,9 +171,25 @@ const QVariantList MemoryUsageModel::getEventDetails(int index) const result << res; } + if (ev->originTypeIndex != -1) { + QVariantMap valuePair; + valuePair.insert(tr("Location"), + d->modelManager->qmlModel()->getEventTypes().at(ev->originTypeIndex).displayName); + result << valuePair; + } + return result; } +struct RangeStackFrame { + RangeStackFrame() : originTypeIndex(-1), startTime(-1), endTime(-1) {} + RangeStackFrame(int originTypeIndex, qint64 startTime, qint64 endTime) : + originTypeIndex(originTypeIndex), startTime(startTime), endTime(endTime) {} + int originTypeIndex; + qint64 startTime; + qint64 endTime; +}; + void MemoryUsageModel::loadData() { Q_D(MemoryUsageModel); @@ -164,40 +202,67 @@ void MemoryUsageModel::loadData() qint64 currentUsage = 0; int currentUsageIndex = -1; int currentJSHeapIndex = -1; + + QStack rangeStack; + MemoryAllocation dummy = { + QmlDebug::MaximumMemoryType, -1, -1 , -1 + }; + const QVector &types = simpleModel->getEventTypes(); foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex]; - if (!eventAccepted(type)) + while (!rangeStack.empty() && rangeStack.top().endTime < event.startTime) + rangeStack.pop(); + if (!eventAccepted(type)) { + if (type.rangeType != QmlDebug::MaximumRangeType) { + rangeStack.push(RangeStackFrame(event.typeIndex, event.startTime, + event.startTime + event.duration)); + } continue; + } if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) { currentUsage += event.numericData1; - MemoryAllocation allocation = { - QmlDebug::SmallItem, - currentUsage, - event.numericData1 - }; - if (currentUsageIndex != -1) { - d->insertEnd(currentUsageIndex, - event.startTime - d->range(currentUsageIndex).start - 1); + MemoryAllocation &last = currentUsageIndex > -1 ? d->data(currentUsageIndex) : dummy; + if (!rangeStack.empty() && last.originTypeIndex == rangeStack.top().originTypeIndex) { + last.size = currentUsage; + last.delta += event.numericData1; + } else { + MemoryAllocation allocation = { + QmlDebug::SmallItem, + currentUsage, + event.numericData1, + rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex + }; + if (currentUsageIndex != -1) { + d->insertEnd(currentUsageIndex, + event.startTime - d->range(currentUsageIndex).start - 1); + } + currentUsageIndex = d->insertStart(event.startTime, allocation); } - currentUsageIndex = d->insertStart(event.startTime, allocation); } if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) { currentSize += event.numericData1; - MemoryAllocation allocation = { - (QmlDebug::MemoryType)type.detailType, - currentSize, - event.numericData1 - }; + MemoryAllocation &last = currentJSHeapIndex > -1 ? d->data(currentJSHeapIndex) : dummy; + if (!rangeStack.empty() && last.originTypeIndex == rangeStack.top().originTypeIndex) { + last.size = currentSize; + last.delta += event.numericData1; + } else { + MemoryAllocation allocation = { + (QmlDebug::MemoryType)type.detailType, + currentSize, + event.numericData1, + rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex + }; - if (currentSize > d->maxSize) - d->maxSize = currentSize; - if (currentJSHeapIndex != -1) - d->insertEnd(currentJSHeapIndex, - event.startTime - d->range(currentJSHeapIndex).start - 1); - currentJSHeapIndex = d->insertStart(event.startTime, allocation); + if (currentSize > d->maxSize) + d->maxSize = currentSize; + if (currentJSHeapIndex != -1) + d->insertEnd(currentJSHeapIndex, + event.startTime - d->range(currentJSHeapIndex).start - 1); + currentJSHeapIndex = d->insertStart(event.startTime, allocation); + } } d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count()); diff --git a/plugins/qmlprofilerextension/memoryusagemodel.h b/plugins/qmlprofilerextension/memoryusagemodel.h index c256b02590e..7559c9c7493 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.h +++ b/plugins/qmlprofilerextension/memoryusagemodel.h @@ -38,6 +38,7 @@ public: QmlDebug::MemoryType type; qint64 size; qint64 delta; + int originTypeIndex; }; MemoryUsageModel(QObject *parent = 0); @@ -50,6 +51,8 @@ public: QColor getColor(int index) const; float getHeight(int index) const; + const QVariantMap getEventLocation(int index) const; + const QVariantList getLabels() const; const QVariantList getEventDetails(int index) const; From fafe9b116c0edc2d4d9fc875ccfc53623a886a19 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Jun 2014 12:47:49 +0200 Subject: [PATCH 6/6] Fix switched times for windows render loop. Task-number: QTBUG-39876 Change-Id: I01c15ede43a9d94fdfc3123b6df8a235430cfc81 Reviewed-by: Kai Koehne --- plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp index a29ddfe1b3a..59dcba30286 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp @@ -285,11 +285,11 @@ void SceneGraphTimelineModel::loadData() break; } case SceneGraphWindowsAnimations: { - timing[14] = event.numericData1; + timing[15] = event.numericData1; break; } case SceneGraphWindowsPolishFrame: { - timing[15] = event.numericData1; + timing[14] = event.numericData1; break; } default: break;