Merge remote-tracking branch 'origin/4.1'

Change-Id: Ieaddc6093d10c08a54acb9b57cbbfe022bc3c038
This commit is contained in:
Orgad Shaneh
2016-09-22 11:01:16 +03:00
21 changed files with 1969 additions and 887 deletions

View File

@@ -99,7 +99,7 @@ void DebugMessagesModel::loadEvent(const QmlEvent &event, const QmlEventType &ty
m_data.insert(insert(event.timestamp(), 0, type.detailType()),
MessageData(event.string(), event.typeIndex()));
if (type.detailType() > m_maximumMsgType)
m_maximumMsgType = event.typeIndex();
m_maximumMsgType = type.detailType();
}
void DebugMessagesModel::finalize()

View File

@@ -44,7 +44,9 @@ FlameGraphModel::FlameGraphModel(QmlProfilerModelManager *modelManager,
{
m_modelManager = modelManager;
m_callStack.append(QmlEvent());
m_stackTop = &m_stackBottom;
m_compileStack.append(QmlEvent());
m_callStackTop = &m_stackBottom;
m_compileStackTop = &m_stackBottom;
connect(modelManager, &QmlProfilerModelManager::stateChanged,
this, &FlameGraphModel::onModelManagerStateChanged);
connect(modelManager->notesModel(), &Timeline::TimelineNotesModel::changed,
@@ -64,8 +66,11 @@ void FlameGraphModel::clear()
beginResetModel();
m_stackBottom = FlameGraphData(0, -1, 1);
m_callStack.clear();
m_compileStack.clear();
m_callStack.append(QmlEvent());
m_stackTop = &m_stackBottom;
m_compileStack.append(QmlEvent());
m_callStackTop = &m_stackBottom;
m_compileStackTop = &m_stackBottom;
m_typeIdsWithNotes.clear();
endResetModel();
}
@@ -99,7 +104,11 @@ void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
if (m_stackBottom.children.isEmpty())
beginResetModel();
const QmlEvent *potentialParent = &(m_callStack.top());
const bool isCompiling = (type.rangeType() == Compiling);
QStack<QmlEvent> &stack = isCompiling ? m_compileStack : m_callStack;
FlameGraphData *&stackTop = isCompiling ? m_compileStackTop : m_callStackTop;
const QmlEvent *potentialParent = &(stack.top());
if (type.message() == MemoryAllocation) {
if (type.detailType() == HeapPage)
return; // We're only interested in actual allocations, not heap pages being mmap'd
@@ -108,20 +117,20 @@ void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
if (amount < 0)
return; // We're not interested in GC runs here
for (FlameGraphData *data = m_stackTop; data; data = data->parent) {
for (FlameGraphData *data = stackTop; data; data = data->parent) {
++data->allocations;
data->memory += amount;
}
} else if (event.rangeStage() == RangeEnd) {
m_stackTop->duration += event.timestamp() - potentialParent->timestamp();
m_callStack.pop();
m_stackTop = m_stackTop->parent;
potentialParent = &(m_callStack.top());
stackTop->duration += event.timestamp() - potentialParent->timestamp();
stack.pop();
stackTop = stackTop->parent;
potentialParent = &(stack.top());
} else {
QTC_ASSERT(event.rangeStage() == RangeStart, return);
m_callStack.push(event);
m_stackTop = pushChild(m_stackTop, event);
stack.push(event);
stackTop = pushChild(stackTop, event);
}
}

View File

@@ -101,8 +101,10 @@ private:
// used by binding loop detection
QStack<QmlEvent> m_callStack;
QStack<QmlEvent> m_compileStack;
FlameGraphData m_stackBottom;
FlameGraphData *m_stackTop;
FlameGraphData *m_callStackTop;
FlameGraphData *m_compileStackTop;
int m_modelId;
QmlProfilerModelManager *m_modelManager;

View File

@@ -36,7 +36,7 @@ MemoryUsageModel::MemoryUsageModel(QmlProfilerModelManager *manager, QObject *pa
QmlProfilerTimelineModel(manager, MemoryAllocation, MaximumRangeType, ProfileMemory, parent)
{
// Announce additional features. The base class already announces the main feature.
announceFeatures(Constants::QML_JS_RANGE_FEATURES);
announceFeatures(Constants::QML_JS_RANGE_FEATURES ^ (1 << ProfileCompiling));
}
int MemoryUsageModel::rowMaxValue(int rowNumber) const
@@ -128,7 +128,8 @@ QVariantMap MemoryUsageModel::details(int index) const
bool MemoryUsageModel::accepted(const QmlEventType &type) const
{
return QmlProfilerTimelineModel::accepted(type) || type.rangeType() != MaximumRangeType;
return QmlProfilerTimelineModel::accepted(type)
|| (type.rangeType() != MaximumRangeType && type.rangeType() != Compiling);
}
void MemoryUsageModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
@@ -258,6 +259,14 @@ void MemoryUsageModel::clear()
QmlProfilerTimelineModel::clear();
}
bool MemoryUsageModel::handlesTypeId(int typeId) const
{
Q_UNUSED(typeId);
// We don't want the memory ranges allocated by some QML/JS function to be highlighted when
// propagating a typeId selection to the timeline. The actual range should be highlighted.
return false;
}
MemoryUsageModel::MemoryAllocationItem::MemoryAllocationItem(int typeId, qint64 baseAmount) :
size(baseAmount), allocated(0), deallocated(0), allocations(0), deallocations(0),
typeId(typeId)

View File

@@ -71,6 +71,7 @@ public:
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
bool handlesTypeId(int typeId) const override;
private:
struct RangeStackFrame {