forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/3.2'
Change-Id: Ifa2b9350ed68b42a04f589368492d318548dc7e2
This commit is contained in:
@@ -139,45 +139,37 @@ const QVariantList MemoryUsageModel::getLabels() const
|
|||||||
const QVariantList MemoryUsageModel::getEventDetails(int index) const
|
const QVariantList MemoryUsageModel::getEventDetails(int index) const
|
||||||
{
|
{
|
||||||
Q_D(const MemoryUsageModel);
|
Q_D(const MemoryUsageModel);
|
||||||
|
static QString title = QStringLiteral("title");
|
||||||
|
|
||||||
QVariantList result;
|
QVariantList result;
|
||||||
const MemoryUsageModelPrivate::Range *ev = &d->range(index);
|
const MemoryUsageModelPrivate::Range *ev = &d->range(index);
|
||||||
|
|
||||||
{
|
QVariantMap res;
|
||||||
QVariantMap res;
|
if (ev->allocated >= -ev->deallocated)
|
||||||
if (ev->size > 0)
|
res.insert(title, tr("Memory Allocated"));
|
||||||
res.insert(QLatin1String("title"), QVariant(QLatin1String("Memory Allocated")));
|
else
|
||||||
else
|
res.insert(title, tr("Memory Freed"));
|
||||||
res.insert(QLatin1String("title"), QVariant(QLatin1String("Memory Freed")));
|
result << res;
|
||||||
|
res.clear();
|
||||||
|
|
||||||
result << res;
|
res.insert(tr("Total"), QVariant(QString::fromLatin1("%1 bytes").arg(ev->size)));
|
||||||
|
result << res;
|
||||||
|
res.clear();
|
||||||
|
|
||||||
|
if (ev->allocations > 0) {
|
||||||
|
res.insert(tr("Allocated"), QString::fromLatin1("%1 bytes").arg(ev->allocated));
|
||||||
|
res.insert(tr("Allocations"), QString::number(ev->allocations));
|
||||||
}
|
}
|
||||||
|
if (ev->deallocations > 0) {
|
||||||
{
|
res.insert(tr("Deallocated"), QString::fromLatin1("%1 bytes").arg(-ev->deallocated));
|
||||||
QVariantMap res;
|
res.insert(tr("Deallocations"), QString::number(ev->deallocations));
|
||||||
res.insert(tr("Total"), QVariant(QString::fromLatin1("%1 bytes").arg(ev->size)));
|
|
||||||
result << res;
|
|
||||||
}
|
}
|
||||||
|
res.insert(tr("Type"), QVariant(MemoryUsageModelPrivate::memoryTypeName(ev->type)));
|
||||||
{
|
|
||||||
QVariantMap res;
|
|
||||||
res.insert(tr("Allocation"), QVariant(QString::fromLatin1("%1 bytes").arg(ev->delta)));
|
|
||||||
result << res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
QVariantMap res;
|
|
||||||
res.insert(tr("Type"), QVariant(MemoryUsageModelPrivate::memoryTypeName(ev->type)));
|
|
||||||
result << res;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ev->originTypeIndex != -1) {
|
if (ev->originTypeIndex != -1) {
|
||||||
QVariantMap valuePair;
|
res.insert(tr("Location"),
|
||||||
valuePair.insert(tr("Location"),
|
|
||||||
d->modelManager->qmlModel()->getEventTypes().at(ev->originTypeIndex).displayName);
|
d->modelManager->qmlModel()->getEventTypes().at(ev->originTypeIndex).displayName);
|
||||||
result << valuePair;
|
|
||||||
}
|
}
|
||||||
|
result << res;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,9 +196,7 @@ void MemoryUsageModel::loadData()
|
|||||||
int currentJSHeapIndex = -1;
|
int currentJSHeapIndex = -1;
|
||||||
|
|
||||||
QStack<RangeStackFrame> rangeStack;
|
QStack<RangeStackFrame> rangeStack;
|
||||||
MemoryAllocation dummy = {
|
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()) {
|
||||||
@@ -222,18 +212,18 @@ void MemoryUsageModel::loadData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) {
|
if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) {
|
||||||
currentUsage += event.numericData1;
|
|
||||||
MemoryAllocation &last = currentUsageIndex > -1 ? d->data(currentUsageIndex) : dummy;
|
MemoryAllocation &last = currentUsageIndex > -1 ? d->data(currentUsageIndex) : dummy;
|
||||||
if (!rangeStack.empty() && last.originTypeIndex == rangeStack.top().originTypeIndex) {
|
if (!rangeStack.empty() && type.detailType == last.type &&
|
||||||
last.size = currentUsage;
|
last.originTypeIndex == rangeStack.top().originTypeIndex &&
|
||||||
last.delta += event.numericData1;
|
rangeStack.top().startTime < d->range(currentUsageIndex).start) {
|
||||||
|
last.update(event.numericData1);
|
||||||
|
currentUsage = last.size;
|
||||||
} else {
|
} else {
|
||||||
MemoryAllocation allocation = {
|
MemoryAllocation allocation(QmlDebug::SmallItem, currentUsage,
|
||||||
QmlDebug::SmallItem,
|
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex);
|
||||||
currentUsage,
|
allocation.update(event.numericData1);
|
||||||
event.numericData1,
|
currentUsage = allocation.size;
|
||||||
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex
|
|
||||||
};
|
|
||||||
if (currentUsageIndex != -1) {
|
if (currentUsageIndex != -1) {
|
||||||
d->insertEnd(currentUsageIndex,
|
d->insertEnd(currentUsageIndex,
|
||||||
event.startTime - d->range(currentUsageIndex).start - 1);
|
event.startTime - d->range(currentUsageIndex).start - 1);
|
||||||
@@ -243,18 +233,17 @@ void MemoryUsageModel::loadData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) {
|
if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) {
|
||||||
currentSize += event.numericData1;
|
|
||||||
MemoryAllocation &last = currentJSHeapIndex > -1 ? d->data(currentJSHeapIndex) : dummy;
|
MemoryAllocation &last = currentJSHeapIndex > -1 ? d->data(currentJSHeapIndex) : dummy;
|
||||||
if (!rangeStack.empty() && last.originTypeIndex == rangeStack.top().originTypeIndex) {
|
if (!rangeStack.empty() && type.detailType == last.type &&
|
||||||
last.size = currentSize;
|
last.originTypeIndex == rangeStack.top().originTypeIndex &&
|
||||||
last.delta += event.numericData1;
|
rangeStack.top().startTime < d->range(currentJSHeapIndex).start) {
|
||||||
|
last.update(event.numericData1);
|
||||||
|
currentSize = last.size;
|
||||||
} else {
|
} else {
|
||||||
MemoryAllocation allocation = {
|
MemoryAllocation allocation((QmlDebug::MemoryType)type.detailType, currentSize,
|
||||||
(QmlDebug::MemoryType)type.detailType,
|
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex);
|
||||||
currentSize,
|
allocation.update(event.numericData1);
|
||||||
event.numericData1,
|
currentSize = allocation.size;
|
||||||
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex
|
|
||||||
};
|
|
||||||
|
|
||||||
if (currentSize > d->maxSize)
|
if (currentSize > d->maxSize)
|
||||||
d->maxSize = currentSize;
|
d->maxSize = currentSize;
|
||||||
@@ -301,6 +290,25 @@ QString MemoryUsageModel::MemoryUsageModelPrivate::memoryTypeName(int type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemoryUsageModel::MemoryAllocation::MemoryAllocation(QmlDebug::MemoryType type, qint64 baseAmount,
|
||||||
|
int originTypeIndex) :
|
||||||
|
type(type), size(baseAmount), allocated(0), deallocated(0), allocations(0), deallocations(0),
|
||||||
|
originTypeIndex(originTypeIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MemoryUsageModel::MemoryAllocation::update(qint64 amount)
|
||||||
|
{
|
||||||
|
size += amount;
|
||||||
|
if (amount < 0) {
|
||||||
|
deallocated += amount;
|
||||||
|
++deallocations;
|
||||||
|
} else {
|
||||||
|
allocated += amount;
|
||||||
|
++allocations;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QmlProfilerExtension
|
} // namespace QmlProfilerExtension
|
||||||
|
@@ -37,8 +37,15 @@ public:
|
|||||||
struct MemoryAllocation {
|
struct MemoryAllocation {
|
||||||
QmlDebug::MemoryType type;
|
QmlDebug::MemoryType type;
|
||||||
qint64 size;
|
qint64 size;
|
||||||
qint64 delta;
|
qint64 allocated;
|
||||||
|
qint64 deallocated;
|
||||||
|
int allocations;
|
||||||
|
int deallocations;
|
||||||
int originTypeIndex;
|
int originTypeIndex;
|
||||||
|
|
||||||
|
MemoryAllocation(QmlDebug::MemoryType type = QmlDebug::MaximumMemoryType,
|
||||||
|
qint64 baseAmount = 0, int originTypeIndex = -1);
|
||||||
|
void update(qint64 amount);
|
||||||
};
|
};
|
||||||
|
|
||||||
MemoryUsageModel(QObject *parent = 0);
|
MemoryUsageModel(QObject *parent = 0);
|
||||||
|
Reference in New Issue
Block a user