summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-07-02 11:49:32 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-07-02 11:52:22 +0200
commit1695a020974aa861a386245a1c6ca85db725a787 (patch)
tree2a48571e771e4e64492f0eb12965143c0beaed95
parent71f04e35d7cb9f10d634cd88f2b3ca4a5f47560d (diff)
parentfafe9b116c0edc2d4d9fc875ccfc53623a886a19 (diff)
downloadqt-creator-1695a020974aa861a386245a1c6ca85db725a787.tar.gz
Merge branch '3.2'
Change-Id: I920aa7056923a994c7d54ac31e32b45fcca84394
-rw-r--r--plugins/qmlprofilerextension/memoryusagemodel.cpp122
-rw-r--r--plugins/qmlprofilerextension/memoryusagemodel.h4
-rw-r--r--plugins/qmlprofilerextension/pixmapcachemodel.cpp15
-rw-r--r--plugins/qmlprofilerextension/pixmapcachemodel.h1
-rw-r--r--plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp38
-rw-r--r--qtcreatorplugin.pri4
6 files changed, 140 insertions, 44 deletions
diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp
index 4482715702..8cf9a42158 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 <QDebug>
+#include <QStack>
namespace QmlProfilerExtension {
namespace Internal {
@@ -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,29 @@ 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 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
@@ -89,7 +118,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 +126,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));
@@ -144,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);
@@ -159,40 +202,67 @@ void MemoryUsageModel::loadData()
qint64 currentUsage = 0;
int currentUsageIndex = -1;
int currentJSHeapIndex = -1;
+
+ QStack<RangeStackFrame> rangeStack;
+ MemoryAllocation dummy = {
+ QmlDebug::MaximumMemoryType, -1, -1 , -1
+ };
+
const QVector<QmlProfilerDataModel::QmlEventTypeData> &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
- };
-
- 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);
+ 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);
+ }
}
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count());
diff --git a/plugins/qmlprofilerextension/memoryusagemodel.h b/plugins/qmlprofilerextension/memoryusagemodel.h
index ce7fdb8b74..7559c9c749 100644
--- a/plugins/qmlprofilerextension/memoryusagemodel.h
+++ b/plugins/qmlprofilerextension/memoryusagemodel.h
@@ -38,17 +38,21 @@ public:
QmlDebug::MemoryType type;
qint64 size;
qint64 delta;
+ int originTypeIndex;
};
MemoryUsageModel(QObject *parent = 0);
int rowCount() const;
+ int rowMaxValue(int rowNumber) const;
int getEventRow(int index) const;
int getEventId(int index) const;
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;
diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp
index 1160625629..ec4da50f10 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;
}
@@ -153,7 +163,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 +172,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/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h
index 688be42a1c..888a5f66ed 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;
diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp
index 3f457476f7..59dcba3028 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,20 @@ const QVariantList SceneGraphTimelineModel::getLabels() const
Q_D(const SceneGraphTimelineModel);
QVariantList result;
+ static QVariant renderThreadLabel(labelForSGType(SceneGraphRenderThread));
+ static QVariant guiThreadLabel(labelForSGType(SceneGraphGUIThread));
+
if (d->expanded && !isEmpty()) {
- for (int i = 0; i < MaximumSceneGraphCategoryType; i++) {
+ {
QVariantMap element;
-
- element.insert(QLatin1String("displayName"), QVariant(labelForSGType(i)));
- element.insert(QLatin1String("description"), QVariant(labelForSGType(i)));
- element.insert(QLatin1String("id"), QVariant(i));
+ element.insert(QLatin1String("description"), guiThreadLabel);
+ element.insert(QLatin1String("id"), SceneGraphGUIThread);
+ result << element;
+ }
+ if (d->seenPolishAndSync) {
+ QVariantMap element;
+ element.insert(QLatin1String("description"), renderThreadLabel);
+ element.insert(QLatin1String("id"), SceneGraphRenderThread);
result << element;
}
}
@@ -155,7 +166,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 +264,7 @@ void SceneGraphTimelineModel::loadData()
break;
}
case SceneGraphPolishAndSync: {
+ d->seenPolishAndSync = true;
// GUI thread
SceneGraphEvent newEvent;
newEvent.sgEventType = SceneGraphGUIThread;
@@ -272,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;
@@ -294,6 +307,7 @@ void SceneGraphTimelineModel::clear()
{
Q_D(SceneGraphTimelineModel);
d->clear();
+ d->seenPolishAndSync = false;
d->expanded = false;
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
}
diff --git a/qtcreatorplugin.pri b/qtcreatorplugin.pri
index 6579467a0d..190dbed1c3 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)