Merge branch '3.2'

Change-Id: I920aa7056923a994c7d54ac31e32b45fcca84394
This commit is contained in:
Ulf Hermann
2014-07-02 11:49:32 +02:00
6 changed files with 140 additions and 44 deletions

View File

@@ -22,7 +22,7 @@
#include "qmlprofiler/sortedtimelinemodel.h" #include "qmlprofiler/sortedtimelinemodel.h"
#include "qmlprofiler/abstracttimelinemodel_p.h" #include "qmlprofiler/abstracttimelinemodel_p.h"
#include <QDebug> #include <QStack>
namespace QmlProfilerExtension { namespace QmlProfilerExtension {
namespace Internal { namespace Internal {
@@ -54,6 +54,13 @@ int MemoryUsageModel::rowCount() const
return isEmpty() ? 1 : 3; 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 int MemoryUsageModel::getEventRow(int index) const
{ {
Q_D(const MemoryUsageModel); Q_D(const MemoryUsageModel);
@@ -78,7 +85,29 @@ QColor MemoryUsageModel::getColor(int index) const
float MemoryUsageModel::getHeight(int index) const float MemoryUsageModel::getHeight(int index) const
{ {
Q_D(const MemoryUsageModel); 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 const QVariantList MemoryUsageModel::getLabels() const
@@ -89,7 +118,6 @@ const QVariantList MemoryUsageModel::getLabels() const
if (d->expanded && !isEmpty()) { if (d->expanded && !isEmpty()) {
{ {
QVariantMap element; QVariantMap element;
element.insert(QLatin1String("displayName"), QVariant(tr("Memory Allocation")));
element.insert(QLatin1String("description"), QVariant(tr("Memory Allocation"))); element.insert(QLatin1String("description"), QVariant(tr("Memory Allocation")));
element.insert(QLatin1String("id"), QVariant(QmlDebug::HeapPage)); element.insert(QLatin1String("id"), QVariant(QmlDebug::HeapPage));
@@ -98,7 +126,6 @@ const QVariantList MemoryUsageModel::getLabels() const
{ {
QVariantMap element; QVariantMap element;
element.insert(QLatin1String("displayName"), QVariant(tr("Memory Usage")));
element.insert(QLatin1String("description"), QVariant(tr("Memory Usage"))); element.insert(QLatin1String("description"), QVariant(tr("Memory Usage")));
element.insert(QLatin1String("id"), QVariant(QmlDebug::SmallItem)); element.insert(QLatin1String("id"), QVariant(QmlDebug::SmallItem));
@@ -144,9 +171,25 @@ const QVariantList MemoryUsageModel::getEventDetails(int index) const
result << res; result << res;
} }
if (ev->originTypeIndex != -1) {
QVariantMap valuePair;
valuePair.insert(tr("Location"),
d->modelManager->qmlModel()->getEventTypes().at(ev->originTypeIndex).displayName);
result << valuePair;
}
return result; 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() void MemoryUsageModel::loadData()
{ {
Q_D(MemoryUsageModel); Q_D(MemoryUsageModel);
@@ -159,18 +202,37 @@ void MemoryUsageModel::loadData()
qint64 currentUsage = 0; qint64 currentUsage = 0;
int currentUsageIndex = -1; int currentUsageIndex = -1;
int currentJSHeapIndex = -1; int currentJSHeapIndex = -1;
QStack<RangeStackFrame> rangeStack;
MemoryAllocation dummy = {
QmlDebug::MaximumMemoryType, -1, -1 , -1
};
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes(); const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) {
const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex]; 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; continue;
}
if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) { if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) {
currentUsage += event.numericData1; currentUsage += event.numericData1;
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 = { MemoryAllocation allocation = {
QmlDebug::SmallItem, QmlDebug::SmallItem,
currentUsage, currentUsage,
event.numericData1 event.numericData1,
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex
}; };
if (currentUsageIndex != -1) { if (currentUsageIndex != -1) {
d->insertEnd(currentUsageIndex, d->insertEnd(currentUsageIndex,
@@ -178,13 +240,20 @@ void MemoryUsageModel::loadData()
} }
currentUsageIndex = d->insertStart(event.startTime, allocation); currentUsageIndex = d->insertStart(event.startTime, allocation);
} }
}
if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) { if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) {
currentSize += event.numericData1; 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 = { MemoryAllocation allocation = {
(QmlDebug::MemoryType)type.detailType, (QmlDebug::MemoryType)type.detailType,
currentSize, currentSize,
event.numericData1 event.numericData1,
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex
}; };
if (currentSize > d->maxSize) if (currentSize > d->maxSize)
@@ -194,6 +263,7 @@ void MemoryUsageModel::loadData()
event.startTime - d->range(currentJSHeapIndex).start - 1); event.startTime - d->range(currentJSHeapIndex).start - 1);
currentJSHeapIndex = d->insertStart(event.startTime, allocation); currentJSHeapIndex = d->insertStart(event.startTime, allocation);
} }
}
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count()); d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count());
} }

View File

@@ -38,17 +38,21 @@ public:
QmlDebug::MemoryType type; QmlDebug::MemoryType type;
qint64 size; qint64 size;
qint64 delta; qint64 delta;
int originTypeIndex;
}; };
MemoryUsageModel(QObject *parent = 0); MemoryUsageModel(QObject *parent = 0);
int rowCount() const; int rowCount() const;
int rowMaxValue(int rowNumber) const;
int getEventRow(int index) const; int getEventRow(int index) const;
int getEventId(int index) const; int getEventId(int index) const;
QColor getColor(int index) const; QColor getColor(int index) const;
float getHeight(int index) const; float getHeight(int index) const;
const QVariantMap getEventLocation(int index) const;
const QVariantList getLabels() const; const QVariantList getLabels() const;
const QVariantList getEventDetails(int index) const; const QVariantList getEventDetails(int index) const;

View File

@@ -103,6 +103,16 @@ int PixmapCacheModel::rowCount() const
return d->collapsedRowCount; 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 int PixmapCacheModel::getEventRow(int index) const
{ {
Q_D(const PixmapCacheModel); Q_D(const PixmapCacheModel);
@@ -131,7 +141,7 @@ float PixmapCacheModel::getHeight(int index) const
{ {
Q_D(const PixmapCacheModel); Q_D(const PixmapCacheModel);
if (d->range(index).pixmapEventType == PixmapCacheCountChanged) 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 else
return 1.0f; return 1.0f;
} }
@@ -153,7 +163,6 @@ const QVariantList PixmapCacheModel::getLabels() const
{ {
// Cache Size // Cache Size
QVariantMap element; QVariantMap element;
element.insert(QLatin1String("displayName"), QVariant(QLatin1String("Cache Size")));
element.insert(QLatin1String("description"), QVariant(QLatin1String("Cache Size"))); element.insert(QLatin1String("description"), QVariant(QLatin1String("Cache Size")));
element.insert(QLatin1String("id"), QVariant(0)); element.insert(QLatin1String("id"), QVariant(0));
@@ -163,8 +172,6 @@ const QVariantList PixmapCacheModel::getLabels() const
for (int i=0; i < d->pixmaps.count(); i++) { for (int i=0; i < d->pixmaps.count(); i++) {
// Loading // Loading
QVariantMap element; QVariantMap element;
element.insert(QLatin1String("displayName"),
QVariant(getFilenameOnly(d->pixmaps[i].url)));
element.insert(QLatin1String("description"), element.insert(QLatin1String("description"),
QVariant(getFilenameOnly(d->pixmaps[i].url))); QVariant(getFilenameOnly(d->pixmaps[i].url)));

View File

@@ -56,6 +56,7 @@ public:
PixmapCacheModel(QObject *parent = 0); PixmapCacheModel(QObject *parent = 0);
int rowCount() const; int rowCount() const;
int rowMaxValue(int rowNumber) const;
int getEventRow(int index) const; int getEventRow(int index) const;
Q_INVOKABLE int getEventId(int index) const; Q_INVOKABLE int getEventId(int index) const;

View File

@@ -46,8 +46,8 @@ enum SceneGraphEventType {
}; };
enum SceneGraphCategoryType { enum SceneGraphCategoryType {
SceneGraphRenderThread,
SceneGraphGUIThread, SceneGraphGUIThread,
SceneGraphRenderThread,
MaximumSceneGraphCategoryType MaximumSceneGraphCategoryType
}; };
@@ -59,6 +59,7 @@ class SceneGraphTimelineModel::SceneGraphTimelineModelPrivate :
public: public:
void addVP(QVariantList &l, QString label, qint64 time) const; void addVP(QVariantList &l, QString label, qint64 time) const;
private: private:
bool seenPolishAndSync;
Q_DECLARE_PUBLIC(SceneGraphTimelineModel) Q_DECLARE_PUBLIC(SceneGraphTimelineModel)
}; };
@@ -67,25 +68,28 @@ SceneGraphTimelineModel::SceneGraphTimelineModel(QObject *parent)
QLatin1String("SceneGraphTimeLineModel"), tr("Scene Graph"), QLatin1String("SceneGraphTimeLineModel"), tr("Scene Graph"),
QmlDebug::SceneGraphFrame, QmlDebug::MaximumRangeType, parent) QmlDebug::SceneGraphFrame, QmlDebug::MaximumRangeType, parent)
{ {
Q_D(SceneGraphTimelineModel);
d->seenPolishAndSync = false;
} }
int SceneGraphTimelineModel::rowCount() const int SceneGraphTimelineModel::rowCount() const
{ {
Q_D(const SceneGraphTimelineModel);
if (isEmpty()) if (isEmpty())
return 1; return 1;
return 3; return d->seenPolishAndSync ? 3 : 2;
} }
int SceneGraphTimelineModel::getEventRow(int index) const int SceneGraphTimelineModel::getEventRow(int index) const
{ {
Q_D(const SceneGraphTimelineModel); 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 int SceneGraphTimelineModel::getEventId(int index) const
{ {
Q_D(const SceneGraphTimelineModel); Q_D(const SceneGraphTimelineModel);
return d->range(index).sgEventType; return d->seenPolishAndSync ? d->range(index).sgEventType : SceneGraphGUIThread;
} }
QColor SceneGraphTimelineModel::getColor(int index) const QColor SceneGraphTimelineModel::getColor(int index) const
@@ -121,13 +125,20 @@ const QVariantList SceneGraphTimelineModel::getLabels() const
Q_D(const SceneGraphTimelineModel); Q_D(const SceneGraphTimelineModel);
QVariantList result; QVariantList result;
if (d->expanded && !isEmpty()) { static QVariant renderThreadLabel(labelForSGType(SceneGraphRenderThread));
for (int i = 0; i < MaximumSceneGraphCategoryType; i++) { static QVariant guiThreadLabel(labelForSGType(SceneGraphGUIThread));
QVariantMap element;
element.insert(QLatin1String("displayName"), QVariant(labelForSGType(i))); if (d->expanded && !isEmpty()) {
element.insert(QLatin1String("description"), QVariant(labelForSGType(i))); {
element.insert(QLatin1String("id"), QVariant(i)); QVariantMap element;
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; result << element;
} }
} }
@@ -155,7 +166,8 @@ const QVariantList SceneGraphTimelineModel::getEventDetails(int index) const
{ {
QVariantMap res; QVariantMap res;
res.insert(QLatin1String("title"), QVariant(labelForSGType(ev->sgEventType))); res.insert(QLatin1String("title"), QVariant(labelForSGType(
d->seenPolishAndSync ? ev->sgEventType : SceneGraphGUIThread)));
result << res; result << res;
} }
@@ -252,6 +264,7 @@ void SceneGraphTimelineModel::loadData()
break; break;
} }
case SceneGraphPolishAndSync: { case SceneGraphPolishAndSync: {
d->seenPolishAndSync = true;
// GUI thread // GUI thread
SceneGraphEvent newEvent; SceneGraphEvent newEvent;
newEvent.sgEventType = SceneGraphGUIThread; newEvent.sgEventType = SceneGraphGUIThread;
@@ -272,11 +285,11 @@ void SceneGraphTimelineModel::loadData()
break; break;
} }
case SceneGraphWindowsAnimations: { case SceneGraphWindowsAnimations: {
timing[14] = event.numericData1; timing[15] = event.numericData1;
break; break;
} }
case SceneGraphWindowsPolishFrame: { case SceneGraphWindowsPolishFrame: {
timing[15] = event.numericData1; timing[14] = event.numericData1;
break; break;
} }
default: break; default: break;
@@ -294,6 +307,7 @@ void SceneGraphTimelineModel::clear()
{ {
Q_D(SceneGraphTimelineModel); Q_D(SceneGraphTimelineModel);
d->clear(); d->clear();
d->seenPolishAndSync = false;
d->expanded = false; d->expanded = false;
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
} }

View File

@@ -1,5 +1,5 @@
IDE_SOURCE_TREE=$$(QTC_SOURCE) isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE=$$(QTC_SOURCE)
IDE_BUILD_TREE=$$(QTC_BUILD) isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE=$$(QTC_BUILD)
isEmpty(IDE_SOURCE_TREE):error(Set QTC_SOURCE environment variable) isEmpty(IDE_SOURCE_TREE):error(Set QTC_SOURCE environment variable)
isEmpty(IDE_BUILD_TREE):error(Set QTC_BUILD environment variable) isEmpty(IDE_BUILD_TREE):error(Set QTC_BUILD environment variable)