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/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,18 +202,37 @@ 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 &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
event.numericData1,
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex
};
if (currentUsageIndex != -1) {
d->insertEnd(currentUsageIndex,
@@ -178,13 +240,20 @@ void MemoryUsageModel::loadData()
}
currentUsageIndex = d->insertStart(event.startTime, allocation);
}
}
if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) {
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
event.numericData1,
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex
};
if (currentSize > d->maxSize)
@@ -194,6 +263,7 @@ void MemoryUsageModel::loadData()
event.startTime - d->range(currentJSHeapIndex).start - 1);
currentJSHeapIndex = d->insertStart(event.startTime, allocation);
}
}
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count());
}

View File

@@ -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;

View File

@@ -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)));

View File

@@ -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;

View File

@@ -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;
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("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);
}

View File

@@ -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)