forked from qt-creator/qt-creator
Move QmlProfiler specific files from qmldebug to qmlprofiler
These file were not used anywhere else and had no business to be in qmldebug to begin with. Moving them allows us to drop a number of namespace qualifications and forces us to rename a few local symbols in other classes in order to avoid name clashes. Change-Id: I658ed455eec027cbaddacf2980d2ea6827ae6205 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
@@ -30,12 +30,12 @@ namespace Internal {
|
||||
|
||||
bool DebugMessagesModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
|
||||
{
|
||||
return event.message == QmlDebug::DebugMessage;
|
||||
return event.message == DebugMessage;
|
||||
}
|
||||
|
||||
DebugMessagesModel::DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, QmlDebug::DebugMessage, QmlDebug::MaximumRangeType,
|
||||
QmlDebug::ProfileDebugMessages, parent), m_maximumMsgType(-1)
|
||||
QmlProfilerTimelineModel(manager, DebugMessage, MaximumRangeType, ProfileDebugMessages, parent),
|
||||
m_maximumMsgType(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,8 @@ FlameGraphModel::FlameGraphModel(QmlProfilerModelManager *modelManager,
|
||||
// We're iterating twice in loadData.
|
||||
modelManager->setProxyCountWeight(m_modelId, 2);
|
||||
|
||||
m_acceptedTypes << QmlDebug::Compiling << QmlDebug::Creating << QmlDebug::Binding
|
||||
<< QmlDebug::HandlingSignal << QmlDebug::Javascript;
|
||||
modelManager->announceFeatures(m_modelId, QmlDebug::Constants::QML_JS_RANGE_FEATURES);
|
||||
m_acceptedTypes << Compiling << Creating << Binding << HandlingSignal << Javascript;
|
||||
modelManager->announceFeatures(m_modelId, Constants::QML_JS_RANGE_FEATURES);
|
||||
}
|
||||
|
||||
void FlameGraphModel::clear()
|
||||
@@ -84,7 +83,7 @@ void FlameGraphModel::loadNotes(int typeIndex, bool emitSignal)
|
||||
}
|
||||
|
||||
if (emitSignal)
|
||||
emit dataChanged(QModelIndex(), QModelIndex(), QVector<int>() << Note);
|
||||
emit dataChanged(QModelIndex(), QModelIndex(), QVector<int>() << NoteRole);
|
||||
}
|
||||
|
||||
void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd)
|
||||
@@ -150,15 +149,15 @@ void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd)
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
static QString nameForType(QmlDebug::RangeType typeNumber)
|
||||
static QString nameForType(RangeType typeNumber)
|
||||
{
|
||||
switch (typeNumber) {
|
||||
case QmlDebug::Painting: return FlameGraphModel::tr("Paint");
|
||||
case QmlDebug::Compiling: return FlameGraphModel::tr("Compile");
|
||||
case QmlDebug::Creating: return FlameGraphModel::tr("Create");
|
||||
case QmlDebug::Binding: return FlameGraphModel::tr("Binding");
|
||||
case QmlDebug::HandlingSignal: return FlameGraphModel::tr("Signal");
|
||||
case QmlDebug::Javascript: return FlameGraphModel::tr("JavaScript");
|
||||
case Painting: return FlameGraphModel::tr("Paint");
|
||||
case Compiling: return FlameGraphModel::tr("Compile");
|
||||
case Creating: return FlameGraphModel::tr("Create");
|
||||
case Binding: return FlameGraphModel::tr("Binding");
|
||||
case HandlingSignal: return FlameGraphModel::tr("Signal");
|
||||
case Javascript: return FlameGraphModel::tr("JavaScript");
|
||||
default: return QString();
|
||||
}
|
||||
}
|
||||
@@ -166,8 +165,8 @@ static QString nameForType(QmlDebug::RangeType typeNumber)
|
||||
QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case TypeId: return stats.typeIndex;
|
||||
case Note: {
|
||||
case TypeIdRole: return stats.typeIndex;
|
||||
case NoteRole: {
|
||||
QString ret;
|
||||
if (!m_typeIdsWithNotes.contains(stats.typeIndex))
|
||||
return ret;
|
||||
@@ -180,10 +179,10 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
case Duration: return stats.duration;
|
||||
case CallCount: return stats.calls;
|
||||
case TimePerCall: return stats.duration / stats.calls;
|
||||
case TimeInPercent: return stats.duration * 100 / m_stackBottom.duration;
|
||||
case DurationRole: return stats.duration;
|
||||
case CallCountRole: return stats.calls;
|
||||
case TimePerCallRole: return stats.duration / stats.calls;
|
||||
case TimeInPercentRole: return stats.duration * 100 / m_stackBottom.duration;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -193,14 +192,14 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const
|
||||
const QmlProfilerDataModel::QmlEventTypeData &type = typeList[stats.typeIndex];
|
||||
|
||||
switch (role) {
|
||||
case Filename: return type.location.filename;
|
||||
case Line: return type.location.line;
|
||||
case Column: return type.location.column;
|
||||
case Type: return nameForType(type.rangeType);
|
||||
case RangeType: return type.rangeType;
|
||||
case Details: return type.data.isEmpty() ?
|
||||
case FilenameRole: return type.location.filename;
|
||||
case LineRole: return type.location.line;
|
||||
case ColumnRole: return type.location.column;
|
||||
case TypeRole: return nameForType(type.rangeType);
|
||||
case RangeTypeRole: return type.rangeType;
|
||||
case DetailsRole: return type.data.isEmpty() ?
|
||||
FlameGraphModel::tr("Source code not available") : type.data;
|
||||
case Location: return type.displayName;
|
||||
case LocationRole: return type.displayName;
|
||||
default: return QVariant();
|
||||
}
|
||||
} else {
|
||||
@@ -277,18 +276,18 @@ QVariant FlameGraphModel::data(const QModelIndex &index, int role) const
|
||||
QHash<int, QByteArray> FlameGraphModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> names = QAbstractItemModel::roleNames();
|
||||
names[TypeId] = "typeId";
|
||||
names[Type] = "type";
|
||||
names[Duration] = "duration";
|
||||
names[CallCount] = "callCount";
|
||||
names[Details] = "details";
|
||||
names[Filename] = "filename";
|
||||
names[Line] = "line";
|
||||
names[Column] = "column";
|
||||
names[Note] = "note";
|
||||
names[TimePerCall] = "timePerCall";
|
||||
names[TimeInPercent] = "timeInPercent";
|
||||
names[RangeType] = "rangeType";
|
||||
names[TypeIdRole] = "typeId";
|
||||
names[TypeRole] = "type";
|
||||
names[DurationRole] = "duration";
|
||||
names[CallCountRole] = "callCount";
|
||||
names[DetailsRole] = "details";
|
||||
names[FilenameRole] = "filename";
|
||||
names[LineRole] = "line";
|
||||
names[ColumnRole] = "column";
|
||||
names[NoteRole] = "note";
|
||||
names[TimePerCallRole] = "timePerCall";
|
||||
names[TimeInPercentRole] = "timeInPercent";
|
||||
names[RangeTypeRole] = "rangeType";
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmlprofiler/qmlprofilerdatamodel.h>
|
||||
#include <qmlprofiler/qmlprofilernotesmodel.h>
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include "qmlprofilernotesmodel.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventlocation.h"
|
||||
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
@@ -55,19 +55,19 @@ class FlameGraphModel : public QAbstractItemModel
|
||||
Q_ENUMS(Role)
|
||||
public:
|
||||
enum Role {
|
||||
TypeId = Qt::UserRole + 1, // Sort by data, not by displayed string
|
||||
Type,
|
||||
Duration,
|
||||
CallCount,
|
||||
Details,
|
||||
Filename,
|
||||
Line,
|
||||
Column,
|
||||
Note,
|
||||
TimePerCall,
|
||||
TimeInPercent,
|
||||
RangeType,
|
||||
Location,
|
||||
TypeIdRole = Qt::UserRole + 1, // Sort by data, not by displayed string
|
||||
TypeRole,
|
||||
DurationRole,
|
||||
CallCountRole,
|
||||
DetailsRole,
|
||||
FilenameRole,
|
||||
LineRole,
|
||||
ColumnRole,
|
||||
NoteRole,
|
||||
TimePerCallRole,
|
||||
TimeInPercentRole,
|
||||
RangeTypeRole,
|
||||
LocationRole,
|
||||
MaxRole
|
||||
};
|
||||
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
int m_modelId;
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
|
||||
QList<QmlDebug::RangeType> m_acceptedTypes;
|
||||
QList<RangeType> m_acceptedTypes;
|
||||
QSet<int> m_typeIdsWithNotes;
|
||||
};
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ void FlameGraphView::selectByTypeId(int typeIndex)
|
||||
void FlameGraphView::onVisibleFeaturesChanged(quint64 features)
|
||||
{
|
||||
int rangeTypeMask = 0;
|
||||
for (int rangeType = 0; rangeType < QmlDebug::MaximumRangeType; ++rangeType) {
|
||||
if (features & (1ULL << QmlDebug::featureFromRangeType(QmlDebug::RangeType(rangeType))))
|
||||
for (int rangeType = 0; rangeType < MaximumRangeType; ++rangeType) {
|
||||
if (features & (1ULL << featureFromRangeType(RangeType(rangeType))))
|
||||
rangeTypeMask |= (1 << rangeType);
|
||||
}
|
||||
m_content->rootObject()->setProperty("visibleRangeTypes", rangeTypeMask);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "inputeventsmodel.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmldebug/qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
@@ -35,15 +35,14 @@ namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
InputEventsModel::InputEventsModel(QmlProfilerModelManager *manager, QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, QmlDebug::Event, QmlDebug::MaximumRangeType,
|
||||
QmlDebug::ProfileInputEvents, parent),
|
||||
QmlProfilerTimelineModel(manager, Event, MaximumRangeType, ProfileInputEvents, parent),
|
||||
m_keyTypeId(-1), m_mouseTypeId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
int InputEventsModel::typeId(int index) const
|
||||
{
|
||||
return selectionId(index) == QmlDebug::Mouse ? m_mouseTypeId : m_keyTypeId;
|
||||
return selectionId(index) == Mouse ? m_mouseTypeId : m_keyTypeId;
|
||||
}
|
||||
|
||||
QColor InputEventsModel::color(int index) const
|
||||
@@ -57,12 +56,12 @@ QVariantList InputEventsModel::labels() const
|
||||
|
||||
QVariantMap element;
|
||||
element.insert(QLatin1String("description"), QVariant(tr("Mouse Events")));
|
||||
element.insert(QLatin1String("id"), QVariant(QmlDebug::Mouse));
|
||||
element.insert(QLatin1String("id"), QVariant(Mouse));
|
||||
result << element;
|
||||
|
||||
element.clear();
|
||||
element.insert(QLatin1String("description"), QVariant(tr("Keyboard Events")));
|
||||
element.insert(QLatin1String("id"), QVariant(QmlDebug::Key));
|
||||
element.insert(QLatin1String("id"), QVariant(Key));
|
||||
result << element;
|
||||
|
||||
return result;
|
||||
@@ -80,9 +79,9 @@ QVariantMap InputEventsModel::details(int index) const
|
||||
QString type;
|
||||
const InputEvent &event = m_data[index];
|
||||
switch (event.type) {
|
||||
case QmlDebug::InputKeyPress:
|
||||
case InputKeyPress:
|
||||
type = tr("Key Press");
|
||||
case QmlDebug::InputKeyRelease:
|
||||
case InputKeyRelease:
|
||||
if (type.isEmpty())
|
||||
type = tr("Key Release");
|
||||
if (event.a != 0) {
|
||||
@@ -93,31 +92,31 @@ QVariantMap InputEventsModel::details(int index) const
|
||||
QLatin1String(metaEnum("KeyboardModifiers").valueToKeys(event.b)));
|
||||
}
|
||||
break;
|
||||
case QmlDebug::InputMouseDoubleClick:
|
||||
case InputMouseDoubleClick:
|
||||
type = tr("Double Click");
|
||||
case QmlDebug::InputMousePress:
|
||||
case InputMousePress:
|
||||
if (type.isEmpty())
|
||||
type = tr("Mouse Press");
|
||||
case QmlDebug::InputMouseRelease:
|
||||
case InputMouseRelease:
|
||||
if (type.isEmpty())
|
||||
type = tr("Mouse Release");
|
||||
result.insert(tr("Button"), QLatin1String(metaEnum("MouseButtons").valueToKey(event.a)));
|
||||
result.insert(tr("Result"), QLatin1String(metaEnum("MouseButtons").valueToKeys(event.b)));
|
||||
break;
|
||||
case QmlDebug::InputMouseMove:
|
||||
case InputMouseMove:
|
||||
type = tr("Mouse Move");
|
||||
result.insert(tr("X"), QString::number(event.a));
|
||||
result.insert(tr("Y"), QString::number(event.b));
|
||||
break;
|
||||
case QmlDebug::InputMouseWheel:
|
||||
case InputMouseWheel:
|
||||
type = tr("Mouse Wheel");
|
||||
result.insert(tr("Angle X"), QString::number(event.a));
|
||||
result.insert(tr("Angle Y"), QString::number(event.b));
|
||||
break;
|
||||
case QmlDebug::InputKeyUnknown:
|
||||
case InputKeyUnknown:
|
||||
type = tr("Keyboard Event");
|
||||
break;
|
||||
case QmlDebug::InputMouseUnknown:
|
||||
case InputMouseUnknown:
|
||||
type = tr("Mouse Event");
|
||||
break;
|
||||
default:
|
||||
@@ -132,7 +131,7 @@ QVariantMap InputEventsModel::details(int index) const
|
||||
|
||||
int InputEventsModel::expandedRow(int index) const
|
||||
{
|
||||
return selectionId(index) == QmlDebug::Mouse ? 1 : 2;
|
||||
return selectionId(index) == Mouse ? 1 : 2;
|
||||
}
|
||||
|
||||
int InputEventsModel::collapsedRow(int index) const
|
||||
@@ -154,10 +153,10 @@ void InputEventsModel::loadData()
|
||||
continue;
|
||||
|
||||
m_data.insert(insert(event.startTime(), 0, type.detailType),
|
||||
InputEvent(static_cast<QmlDebug::InputEventType>(event.numericData(0)),
|
||||
InputEvent(static_cast<InputEventType>(event.numericData(0)),
|
||||
event.numericData(1), event.numericData(2)));
|
||||
|
||||
if (type.detailType == QmlDebug::Mouse) {
|
||||
if (type.detailType == Mouse) {
|
||||
if (m_mouseTypeId == -1)
|
||||
m_mouseTypeId = event.typeIndex();
|
||||
} else if (m_keyTypeId == -1) {
|
||||
@@ -180,10 +179,10 @@ void InputEventsModel::clear()
|
||||
bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
|
||||
{
|
||||
return QmlProfilerTimelineModel::accepted(event) &&
|
||||
(event.detailType == QmlDebug::Mouse || event.detailType == QmlDebug::Key);
|
||||
(event.detailType == Mouse || event.detailType == Key);
|
||||
}
|
||||
|
||||
InputEventsModel::InputEvent::InputEvent(QmlDebug::InputEventType type, int a, int b) :
|
||||
InputEventsModel::InputEvent::InputEvent(InputEventType type, int a, int b) :
|
||||
type(type), a(a), b(b)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,9 +39,8 @@ protected:
|
||||
|
||||
public:
|
||||
struct InputEvent {
|
||||
InputEvent(QmlDebug::InputEventType type = QmlDebug::MaximumInputEventType, int a = 0,
|
||||
int b = 0);
|
||||
QmlDebug::InputEventType type;
|
||||
InputEvent(InputEventType type = MaximumInputEventType, int a = 0, int b = 0);
|
||||
InputEventType type;
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "memoryusagemodel.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmldebug/qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
#include <QStack>
|
||||
|
||||
@@ -33,11 +33,10 @@ namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
MemoryUsageModel::MemoryUsageModel(QmlProfilerModelManager *manager, QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, QmlDebug::MemoryAllocation, QmlDebug::MaximumRangeType,
|
||||
QmlDebug::ProfileMemory, parent)
|
||||
QmlProfilerTimelineModel(manager, MemoryAllocation, MaximumRangeType, ProfileMemory, parent)
|
||||
{
|
||||
m_maxSize = 1;
|
||||
announceFeatures((1ULL << mainFeature()) | QmlDebug::Constants::QML_JS_RANGE_FEATURES);
|
||||
announceFeatures((1ULL << mainFeature()) | Constants::QML_JS_RANGE_FEATURES);
|
||||
}
|
||||
|
||||
int MemoryUsageModel::rowMaxValue(int rowNumber) const
|
||||
@@ -49,7 +48,7 @@ int MemoryUsageModel::rowMaxValue(int rowNumber) const
|
||||
int MemoryUsageModel::expandedRow(int index) const
|
||||
{
|
||||
int type = selectionId(index);
|
||||
return (type == QmlDebug::HeapPage || type == QmlDebug::LargeItem) ? 1 : 2;
|
||||
return (type == HeapPage || type == LargeItem) ? 1 : 2;
|
||||
}
|
||||
|
||||
int MemoryUsageModel::collapsedRow(int index) const
|
||||
@@ -82,7 +81,7 @@ QVariantMap MemoryUsageModel::location(int index) const
|
||||
|
||||
int originType = m_data[index].originTypeIndex;
|
||||
if (originType > -1) {
|
||||
const QmlDebug::QmlEventLocation &location =
|
||||
const QmlEventLocation &location =
|
||||
modelManager()->qmlModel()->getEventTypes().at(originType).location;
|
||||
|
||||
result.insert(file, location.filename);
|
||||
@@ -99,12 +98,12 @@ QVariantList MemoryUsageModel::labels() const
|
||||
|
||||
QVariantMap element;
|
||||
element.insert(QLatin1String("description"), QVariant(tr("Memory Allocation")));
|
||||
element.insert(QLatin1String("id"), QVariant(QmlDebug::HeapPage));
|
||||
element.insert(QLatin1String("id"), QVariant(HeapPage));
|
||||
result << element;
|
||||
|
||||
element.clear();
|
||||
element.insert(QLatin1String("description"), QVariant(tr("Memory Usage")));
|
||||
element.insert(QLatin1String("id"), QVariant(QmlDebug::SmallItem));
|
||||
element.insert(QLatin1String("id"), QVariant(SmallItem));
|
||||
result << element;
|
||||
|
||||
return result;
|
||||
@@ -113,7 +112,7 @@ QVariantList MemoryUsageModel::labels() const
|
||||
QVariantMap MemoryUsageModel::details(int index) const
|
||||
{
|
||||
QVariantMap result;
|
||||
const MemoryAllocation *ev = &m_data[index];
|
||||
const MemoryAllocationItem *ev = &m_data[index];
|
||||
|
||||
if (ev->allocated >= -ev->deallocated)
|
||||
result.insert(QLatin1String("displayName"), tr("Memory Allocated"));
|
||||
@@ -166,14 +165,14 @@ void MemoryUsageModel::loadData()
|
||||
while (!rangeStack.empty() && rangeStack.top().endTime < event.startTime())
|
||||
rangeStack.pop();
|
||||
if (!accepted(type)) {
|
||||
if (type.rangeType != QmlDebug::MaximumRangeType) {
|
||||
if (type.rangeType != MaximumRangeType) {
|
||||
rangeStack.push(RangeStackFrame(event.typeIndex(), event.startTime(),
|
||||
event.startTime() + event.duration()));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) {
|
||||
if (type.detailType == SmallItem || type.detailType == LargeItem) {
|
||||
if (!rangeStack.empty() && currentUsageIndex > -1 &&
|
||||
type.detailType == selectionId(currentUsageIndex) &&
|
||||
m_data[currentUsageIndex].originTypeIndex == rangeStack.top().originTypeIndex &&
|
||||
@@ -181,7 +180,7 @@ void MemoryUsageModel::loadData()
|
||||
m_data[currentUsageIndex].update(event.numericData(0));
|
||||
currentUsage = m_data[currentUsageIndex].size;
|
||||
} else {
|
||||
MemoryAllocation allocation(event.typeIndex(), currentUsage,
|
||||
MemoryAllocationItem allocation(event.typeIndex(), currentUsage,
|
||||
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex);
|
||||
allocation.update(event.numericData(0));
|
||||
currentUsage = allocation.size;
|
||||
@@ -190,12 +189,12 @@ void MemoryUsageModel::loadData()
|
||||
insertEnd(currentUsageIndex,
|
||||
event.startTime() - startTime(currentUsageIndex) - 1);
|
||||
}
|
||||
currentUsageIndex = insertStart(event.startTime(), QmlDebug::SmallItem);
|
||||
currentUsageIndex = insertStart(event.startTime(), SmallItem);
|
||||
m_data.insert(currentUsageIndex, allocation);
|
||||
}
|
||||
}
|
||||
|
||||
if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) {
|
||||
if (type.detailType == HeapPage || type.detailType == LargeItem) {
|
||||
if (!rangeStack.empty() && currentJSHeapIndex > -1 &&
|
||||
type.detailType == selectionId(currentJSHeapIndex) &&
|
||||
m_data[currentJSHeapIndex].originTypeIndex ==
|
||||
@@ -204,7 +203,7 @@ void MemoryUsageModel::loadData()
|
||||
m_data[currentJSHeapIndex].update(event.numericData(0));
|
||||
currentSize = m_data[currentJSHeapIndex].size;
|
||||
} else {
|
||||
MemoryAllocation allocation(event.typeIndex(), currentSize,
|
||||
MemoryAllocationItem allocation(event.typeIndex(), currentSize,
|
||||
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex);
|
||||
allocation.update(event.numericData(0));
|
||||
currentSize = allocation.size;
|
||||
@@ -246,22 +245,22 @@ void MemoryUsageModel::clear()
|
||||
QString MemoryUsageModel::memoryTypeName(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case QmlDebug::HeapPage: return tr("Heap Allocation");
|
||||
case QmlDebug::LargeItem: return tr("Large Item Allocation");
|
||||
case QmlDebug::SmallItem: return tr("Heap Usage");
|
||||
case QmlDebug::MaximumMemoryType: return tr("Total");
|
||||
case HeapPage: return tr("Heap Allocation");
|
||||
case LargeItem: return tr("Large Item Allocation");
|
||||
case SmallItem: return tr("Heap Usage");
|
||||
case MaximumMemoryType: return tr("Total");
|
||||
default: return tr("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
MemoryUsageModel::MemoryAllocation::MemoryAllocation(int type, qint64 baseAmount,
|
||||
MemoryUsageModel::MemoryAllocationItem::MemoryAllocationItem(int type, qint64 baseAmount,
|
||||
int originTypeIndex) :
|
||||
typeId(type), size(baseAmount), allocated(0), deallocated(0), allocations(0), deallocations(0),
|
||||
originTypeIndex(originTypeIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void MemoryUsageModel::MemoryAllocation::update(qint64 amount)
|
||||
void MemoryUsageModel::MemoryAllocationItem::update(qint64 amount)
|
||||
{
|
||||
size += amount;
|
||||
if (amount < 0) {
|
||||
|
||||
@@ -39,7 +39,7 @@ class MemoryUsageModel : public QmlProfilerTimelineModel
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
struct MemoryAllocation {
|
||||
struct MemoryAllocationItem {
|
||||
int typeId;
|
||||
qint64 size;
|
||||
qint64 allocated;
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
int deallocations;
|
||||
int originTypeIndex;
|
||||
|
||||
MemoryAllocation(int typeId = -1, qint64 baseAmount = 0, int originTypeIndex = -1);
|
||||
MemoryAllocationItem(int typeId = -1, qint64 baseAmount = 0, int originTypeIndex = -1);
|
||||
void update(qint64 amount);
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ protected:
|
||||
private:
|
||||
static QString memoryTypeName(int type);
|
||||
|
||||
QVector<MemoryAllocation> m_data;
|
||||
QVector<MemoryAllocationItem> m_data;
|
||||
qint64 m_maxSize;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
#include "pixmapcachemodel.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmldebug/qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
PixmapCacheModel::PixmapCacheModel(QmlProfilerModelManager *manager, QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, QmlDebug::PixmapCacheEvent, QmlDebug::MaximumRangeType,
|
||||
QmlDebug::ProfilePixmapCache, parent)
|
||||
QmlProfilerTimelineModel(manager, PixmapCacheEvent, MaximumRangeType, ProfilePixmapCache,
|
||||
parent)
|
||||
{
|
||||
m_maxCacheSize = 1;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ QVariantList PixmapCacheModel::labels() const
|
||||
QVariantMap PixmapCacheModel::details(int index) const
|
||||
{
|
||||
QVariantMap result;
|
||||
const PixmapCacheEvent *ev = &m_data[index];
|
||||
const PixmapCacheItem *ev = &m_data[index];
|
||||
|
||||
if (ev->pixmapEventType == PixmapCacheCountChanged) {
|
||||
result.insert(QLatin1String("displayName"), tr("Image Cached"));
|
||||
@@ -180,7 +180,7 @@ void PixmapCacheModel::loadData()
|
||||
if (!accepted(type))
|
||||
continue;
|
||||
|
||||
PixmapCacheEvent newEvent;
|
||||
PixmapCacheItem newEvent;
|
||||
newEvent.pixmapEventType = static_cast<PixmapEventType>(type.detailType);
|
||||
qint64 pixmapStartTime = event.startTime();
|
||||
|
||||
@@ -425,7 +425,7 @@ void PixmapCacheModel::clear()
|
||||
void PixmapCacheModel::computeMaxCacheSize()
|
||||
{
|
||||
m_maxCacheSize = 1;
|
||||
foreach (const PixmapCacheModel::PixmapCacheEvent &event, m_data) {
|
||||
foreach (const PixmapCacheModel::PixmapCacheItem &event, m_data) {
|
||||
if (event.pixmapEventType == PixmapCacheModel::PixmapCacheCountChanged) {
|
||||
if (event.cacheSize > m_maxCacheSize)
|
||||
m_maxCacheSize = event.cacheSize;
|
||||
@@ -451,7 +451,7 @@ void PixmapCacheModel::flattenLoads()
|
||||
// computes "compressed row"
|
||||
QVector <qint64> eventEndTimes;
|
||||
for (int i = 0; i < count(); i++) {
|
||||
PixmapCacheModel::PixmapCacheEvent &event = m_data[i];
|
||||
PixmapCacheModel::PixmapCacheItem &event = m_data[i];
|
||||
if (event.pixmapEventType == PixmapCacheModel::PixmapLoadingStarted) {
|
||||
event.rowNumberCollapsed = 0;
|
||||
while (eventEndTimes.count() > event.rowNumberCollapsed &&
|
||||
@@ -475,7 +475,7 @@ void PixmapCacheModel::flattenLoads()
|
||||
}
|
||||
|
||||
int PixmapCacheModel::updateCacheCount(int lastCacheSizeEvent,
|
||||
qint64 pixmapStartTime, qint64 pixSize, PixmapCacheEvent &newEvent, int typeId)
|
||||
qint64 pixmapStartTime, qint64 pixSize, PixmapCacheItem &newEvent, int typeId)
|
||||
{
|
||||
newEvent.pixmapEventType = PixmapCacheCountChanged;
|
||||
newEvent.rowNumberCollapsed = 1;
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
MaximumPixmapEventType
|
||||
};
|
||||
|
||||
struct PixmapCacheEvent {
|
||||
struct PixmapCacheItem {
|
||||
int typeId;
|
||||
PixmapEventType pixmapEventType;
|
||||
int urlIndex;
|
||||
@@ -114,9 +114,9 @@ private:
|
||||
void resizeUnfinishedLoads();
|
||||
void flattenLoads();
|
||||
int updateCacheCount(int lastCacheSizeEvent, qint64 startTime, qint64 pixSize,
|
||||
PixmapCacheEvent &newEvent, int typeId);
|
||||
PixmapCacheItem &newEvent, int typeId);
|
||||
|
||||
QVector<PixmapCacheEvent> m_data;
|
||||
QVector<PixmapCacheItem> m_data;
|
||||
QVector<Pixmap> m_pixmaps;
|
||||
qint64 m_maxCacheSize;
|
||||
|
||||
|
||||
@@ -59,19 +59,19 @@ ScrollView {
|
||||
width: parent.width
|
||||
height: depth * itemHeight
|
||||
model: flameGraphModel
|
||||
sizeRole: FlameGraphModel.Duration
|
||||
sizeRole: FlameGraphModel.DurationRole
|
||||
sizeThreshold: 0.002
|
||||
y: flickable.height > height ? flickable.height - height : 0
|
||||
|
||||
delegate: Item {
|
||||
id: flamegraphItem
|
||||
|
||||
property int typeId: FlameGraph.data(FlameGraphModel.TypeId) || -1
|
||||
property int typeId: FlameGraph.data(FlameGraphModel.TypeIdRole) || -1
|
||||
property bool isBindingLoop: parent.checkBindingLoop(typeId)
|
||||
property int level: parent.level + (rangeTypeVisible ? 1 : 0)
|
||||
property bool isSelected: typeId !== -1 && typeId === root.selectedTypeId
|
||||
property bool rangeTypeVisible: root.visibleRangeTypes &
|
||||
(1 << FlameGraph.data(FlameGraphModel.RangeType))
|
||||
property bool rangeTypeVisible:
|
||||
root.visibleRangeTypes & (1 << FlameGraph.data(FlameGraphModel.RangeTypeRole))
|
||||
|
||||
onIsSelectedChanged: {
|
||||
if (isSelected && (tooltip.selectedNode === null ||
|
||||
@@ -93,8 +93,8 @@ ScrollView {
|
||||
|
||||
// Functions, not properties to limit the initial overhead when creating the nodes,
|
||||
// and because FlameGraph.data(...) cannot be notified anyway.
|
||||
function title() { return FlameGraph.data(FlameGraphModel.Type) || ""; }
|
||||
function note() { return FlameGraph.data(FlameGraphModel.Note) || ""; }
|
||||
function title() { return FlameGraph.data(FlameGraphModel.TypeRole) || ""; }
|
||||
function note() { return FlameGraph.data(FlameGraphModel.NoteRole) || ""; }
|
||||
function details() {
|
||||
var model = [];
|
||||
function addDetail(name, index, format) {
|
||||
@@ -128,14 +128,14 @@ ScrollView {
|
||||
model.push(qsTr("Details"));
|
||||
model.push(qsTr("Various Events"));
|
||||
} else {
|
||||
addDetail(qsTr("Details"), FlameGraphModel.Details, noop);
|
||||
addDetail(qsTr("Type"), FlameGraphModel.Type, noop);
|
||||
addDetail(qsTr("Calls"), FlameGraphModel.CallCount, noop);
|
||||
addDetail(qsTr("Total Time"), FlameGraphModel.Duration, printTime);
|
||||
addDetail(qsTr("Mean Time"), FlameGraphModel.TimePerCall, printTime);
|
||||
addDetail(qsTr("In Percent"), FlameGraphModel.TimeInPercent,
|
||||
addDetail(qsTr("Details"), FlameGraphModel.DetailsRole, noop);
|
||||
addDetail(qsTr("Type"), FlameGraphModel.TypeRole, noop);
|
||||
addDetail(qsTr("Calls"), FlameGraphModel.CallCountRole, noop);
|
||||
addDetail(qsTr("Total Time"), FlameGraphModel.DurationRole, printTime);
|
||||
addDetail(qsTr("Mean Time"), FlameGraphModel.TimePerCallRole, printTime);
|
||||
addDetail(qsTr("In Percent"), FlameGraphModel.TimeInPercentRole,
|
||||
addPercent);
|
||||
addDetail(qsTr("Location"), FlameGraphModel.Location, noop);
|
||||
addDetail(qsTr("Location"), FlameGraphModel.LocationRole, noop);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
@@ -184,9 +184,12 @@ ScrollView {
|
||||
if (!flamegraphItem.FlameGraph.dataValid)
|
||||
return "<others>";
|
||||
|
||||
return flamegraphItem.FlameGraph.data(FlameGraphModel.Details) + " (" +
|
||||
flamegraphItem.FlameGraph.data(FlameGraphModel.Type) + ", " +
|
||||
flamegraphItem.FlameGraph.data(FlameGraphModel.TimeInPercent) + "%)";
|
||||
return flamegraphItem.FlameGraph.data(FlameGraphModel.DetailsRole)
|
||||
+ " ("
|
||||
+ flamegraphItem.FlameGraph.data(FlameGraphModel.TypeRole)
|
||||
+ ", "
|
||||
+ flamegraphItem.FlameGraph.data(
|
||||
FlameGraphModel.TimeInPercentRole) + "%)";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,12 +209,15 @@ ScrollView {
|
||||
onClicked: {
|
||||
if (flamegraphItem.FlameGraph.dataValid) {
|
||||
tooltip.selectedNode = flamegraphItem;
|
||||
root.typeSelected(
|
||||
flamegraphItem.FlameGraph.data(FlameGraphModel.TypeId));
|
||||
root.typeSelected(flamegraphItem.FlameGraph.data(
|
||||
FlameGraphModel.TypeIdRole));
|
||||
root.gotoSourceLocation(
|
||||
flamegraphItem.FlameGraph.data(FlameGraphModel.Filename),
|
||||
flamegraphItem.FlameGraph.data(FlameGraphModel.Line),
|
||||
flamegraphItem.FlameGraph.data(FlameGraphModel.Column));
|
||||
flamegraphItem.FlameGraph.data(
|
||||
FlameGraphModel.FilenameRole),
|
||||
flamegraphItem.FlameGraph.data(
|
||||
FlameGraphModel.LineRole),
|
||||
flamegraphItem.FlameGraph.data(
|
||||
FlameGraphModel.ColumnRole));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ SOURCES += \
|
||||
qmlprofilerstatisticsview.cpp \
|
||||
qmlprofilertimelinemodel.cpp \
|
||||
qmlprofilertool.cpp \
|
||||
qmlprofilertraceclient.cpp \
|
||||
qmlprofilertracefile.cpp \
|
||||
qmlprofilertraceview.cpp \
|
||||
qmlprofilerviewmanager.cpp \
|
||||
@@ -58,7 +59,9 @@ HEADERS += \
|
||||
qmlprofilerconstants.h \
|
||||
qmlprofilerdatamodel.h \
|
||||
qmlprofilerdetailsrewriter.h \
|
||||
qmlprofilereventlocation.h \
|
||||
qmlprofilereventsview.h \
|
||||
qmlprofilereventtypes.h \
|
||||
qmlprofilermodelmanager.h \
|
||||
qmlprofilernotesmodel.h \
|
||||
qmlprofileroptionspage.h \
|
||||
@@ -74,6 +77,7 @@ HEADERS += \
|
||||
qmlprofilerstatisticsview.h \
|
||||
qmlprofilertimelinemodel.h \
|
||||
qmlprofilertool.h \
|
||||
qmlprofilertraceclient.h \
|
||||
qmlprofilertracefile.h \
|
||||
qmlprofilertraceview.h \
|
||||
qmlprofilerviewmanager.h \
|
||||
|
||||
@@ -36,7 +36,9 @@ QtcPlugin {
|
||||
"qmlprofilerconfigwidget.ui", "qmlprofilerconstants.h",
|
||||
"qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h",
|
||||
"qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h",
|
||||
"qmlprofilereventlocation.h",
|
||||
"qmlprofilereventsview.h",
|
||||
"qmlprofilereventtypes.h",
|
||||
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
|
||||
"qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h",
|
||||
"qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h",
|
||||
@@ -52,6 +54,7 @@ QtcPlugin {
|
||||
"qmlprofilerstatisticsview.cpp", "qmlprofilerstatisticsview.h",
|
||||
"qmlprofilertimelinemodel.cpp", "qmlprofilertimelinemodel.h",
|
||||
"qmlprofilertool.cpp", "qmlprofilertool.h",
|
||||
"qmlprofilertraceclient.cpp", "qmlprofilertraceclient.h",
|
||||
"qmlprofilertracefile.cpp", "qmlprofilertracefile.h",
|
||||
"qmlprofilertraceview.cpp", "qmlprofilertraceview.h",
|
||||
"qmlprofilerviewmanager.cpp", "qmlprofilerviewmanager.h",
|
||||
|
||||
@@ -42,8 +42,7 @@ namespace Internal {
|
||||
|
||||
QmlProfilerAnimationsModel::QmlProfilerAnimationsModel(QmlProfilerModelManager *manager,
|
||||
QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, QmlDebug::Event, QmlDebug::MaximumRangeType,
|
||||
QmlDebug::ProfileAnimations, parent)
|
||||
QmlProfilerTimelineModel(manager, Event, MaximumRangeType, ProfileAnimations, parent)
|
||||
{
|
||||
m_maxGuiThreadAnimations = m_maxRenderThreadAnimations = 0;
|
||||
}
|
||||
@@ -57,8 +56,7 @@ void QmlProfilerAnimationsModel::clear()
|
||||
|
||||
bool QmlProfilerAnimationsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
|
||||
{
|
||||
return QmlProfilerTimelineModel::accepted(event) &&
|
||||
event.detailType== QmlDebug::AnimationFrame;
|
||||
return QmlProfilerTimelineModel::accepted(event) && event.detailType == AnimationFrame;
|
||||
}
|
||||
|
||||
void QmlProfilerAnimationsModel::loadData()
|
||||
@@ -71,7 +69,7 @@ void QmlProfilerAnimationsModel::loadData()
|
||||
const QVector<QmlProfilerDataModel::QmlEventData> &referenceList = simpleModel->getEvents();
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = simpleModel->getEventTypes();
|
||||
|
||||
QmlDebug::AnimationThread lastThread;
|
||||
AnimationThread lastThread;
|
||||
QmlPaintEventData lastEvent;
|
||||
qint64 minNextStartTimes[] = {0, 0};
|
||||
|
||||
@@ -80,7 +78,7 @@ void QmlProfilerAnimationsModel::loadData()
|
||||
if (!accepted(type))
|
||||
continue;
|
||||
|
||||
lastThread = (QmlDebug::AnimationThread)event.numericData(2);
|
||||
lastThread = (AnimationThread)event.numericData(2);
|
||||
|
||||
// initial estimation of the event duration: 1/framerate
|
||||
qint64 estimatedDuration = event.numericData(0) > 0 ? 1e9/event.numericData(0) : 1;
|
||||
@@ -105,7 +103,7 @@ void QmlProfilerAnimationsModel::loadData()
|
||||
|
||||
m_data.insert(insert(realStartTime, realEndTime - realStartTime, lastThread), lastEvent);
|
||||
|
||||
if (lastThread == QmlDebug::GuiThread)
|
||||
if (lastThread == GuiThread)
|
||||
m_maxGuiThreadAnimations = qMax(lastEvent.animationcount, m_maxGuiThreadAnimations);
|
||||
else
|
||||
m_maxRenderThreadAnimations = qMax(lastEvent.animationcount,
|
||||
@@ -124,7 +122,7 @@ void QmlProfilerAnimationsModel::loadData()
|
||||
|
||||
int QmlProfilerAnimationsModel::rowFromThreadId(int threadId) const
|
||||
{
|
||||
return (threadId == QmlDebug::GuiThread || m_maxGuiThreadAnimations == 0) ? 1 : 2;
|
||||
return (threadId == GuiThread || m_maxGuiThreadAnimations == 0) ? 1 : 2;
|
||||
}
|
||||
|
||||
int QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const
|
||||
@@ -166,7 +164,7 @@ QColor QmlProfilerAnimationsModel::color(int index) const
|
||||
|
||||
float QmlProfilerAnimationsModel::relativeHeight(int index) const
|
||||
{
|
||||
return (float)m_data[index].animationcount / (float)(selectionId(index) == QmlDebug::GuiThread ?
|
||||
return (float)m_data[index].animationcount / (float)(selectionId(index) == GuiThread ?
|
||||
m_maxGuiThreadAnimations :
|
||||
m_maxRenderThreadAnimations);
|
||||
}
|
||||
@@ -179,7 +177,7 @@ QVariantList QmlProfilerAnimationsModel::labels() const
|
||||
QVariantMap element;
|
||||
element.insert(QLatin1String("displayName"), QVariant(tr("Animations")));
|
||||
element.insert(QLatin1String("description"), QVariant(tr("GUI Thread")));
|
||||
element.insert(QLatin1String("id"), QVariant(QmlDebug::GuiThread));
|
||||
element.insert(QLatin1String("id"), QVariant(GuiThread));
|
||||
result << element;
|
||||
}
|
||||
|
||||
@@ -187,7 +185,7 @@ QVariantList QmlProfilerAnimationsModel::labels() const
|
||||
QVariantMap element;
|
||||
element.insert(QLatin1String("displayName"), QVariant(tr("Animations")));
|
||||
element.insert(QLatin1String("description"), QVariant(tr("Render Thread")));
|
||||
element.insert(QLatin1String("id"), QVariant(QmlDebug::RenderThread));
|
||||
element.insert(QLatin1String("id"), QVariant(RenderThread));
|
||||
result << element;
|
||||
}
|
||||
|
||||
@@ -202,8 +200,8 @@ QVariantMap QmlProfilerAnimationsModel::details(int index) const
|
||||
result.insert(tr("Duration"), QmlProfilerDataModel::formatTime(duration(index)));
|
||||
result.insert(tr("Framerate"), QString::fromLatin1("%1 FPS").arg(m_data[index].framerate));
|
||||
result.insert(tr("Animations"), QString::fromLatin1("%1").arg(m_data[index].animationcount));
|
||||
result.insert(tr("Context"), tr(selectionId(index) == QmlDebug::GuiThread ? "GUI Thread" :
|
||||
"Render Thread"));
|
||||
result.insert(tr("Context"), tr(selectionId(index) == GuiThread ? "GUI Thread" :
|
||||
"Render Thread"));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,17 +25,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "qmlprofilertimelinemodel.h"
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
//#include <QHash>
|
||||
//#include <QVector>
|
||||
#include <QVariantList>
|
||||
//#include <QVariantMap>
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventlocation.h"
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include <QColor>
|
||||
|
||||
#include <QVariantList>
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
|
||||
namespace QmlProfiler {
|
||||
class QmlProfilerModelManager;
|
||||
|
||||
@@ -26,16 +26,14 @@
|
||||
#include "qmlprofilerclientmanager.h"
|
||||
#include "qmlprofilertool.h"
|
||||
#include "qmlprofilerplugin.h"
|
||||
|
||||
#include <qmldebug/qmlprofilertraceclient.h>
|
||||
#include "qmlprofilertraceclient.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <QPointer>
|
||||
#include <QTimer>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
|
||||
using namespace QmlDebug;
|
||||
using namespace Core;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofilerstatemanager.h"
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include "qmlprofilereventlocation.h"
|
||||
#include <utils/port.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilernotesmodel.h"
|
||||
#include "qmlprofilerdetailsrewriter.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
@@ -68,7 +68,7 @@ QString getInitialDetails(const QmlProfilerDataModel::QmlEventTypeData &event)
|
||||
details = event.data;
|
||||
details = details.replace(QLatin1Char('\n'),QLatin1Char(' ')).simplified();
|
||||
if (details.isEmpty()) {
|
||||
if (event.rangeType == QmlDebug::Javascript)
|
||||
if (event.rangeType == Javascript)
|
||||
details = QmlProfilerDataModel::tr("anonymous function");
|
||||
} else {
|
||||
QRegExp rewrite(QLatin1String("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)"));
|
||||
@@ -79,7 +79,7 @@ QString getInitialDetails(const QmlProfilerDataModel::QmlEventTypeData &event)
|
||||
details.startsWith(QLatin1String("qrc:/")))
|
||||
details = details.mid(details.lastIndexOf(QLatin1Char('/')) + 1);
|
||||
}
|
||||
} else if (event.rangeType == QmlDebug::Painting) {
|
||||
} else if (event.rangeType == Painting) {
|
||||
// QtQuick1 animations always run in GUI thread.
|
||||
details = QmlProfilerDataModel::tr("GUI Thread");
|
||||
}
|
||||
@@ -231,7 +231,7 @@ void QmlProfilerDataModel::processData()
|
||||
// request further details from files
|
||||
//
|
||||
|
||||
if (event->rangeType != QmlDebug::Binding && event->rangeType != QmlDebug::HandlingSignal)
|
||||
if (event->rangeType != Binding && event->rangeType != HandlingSignal)
|
||||
continue;
|
||||
|
||||
// This skips anonymous bindings in Qt4.8 (we don't have valid location data for them)
|
||||
@@ -251,19 +251,17 @@ void QmlProfilerDataModel::processData()
|
||||
emit requestReload();
|
||||
}
|
||||
|
||||
void QmlProfilerDataModel::addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType,
|
||||
int detailType, qint64 startTime,
|
||||
qint64 duration, const QString &data,
|
||||
const QmlDebug::QmlEventLocation &location,
|
||||
qint64 ndata1, qint64 ndata2, qint64 ndata3,
|
||||
qint64 ndata4, qint64 ndata5)
|
||||
void QmlProfilerDataModel::addQmlEvent(Message message, RangeType rangeType, int detailType,
|
||||
qint64 startTime, qint64 duration, const QString &data,
|
||||
const QmlEventLocation &location, qint64 ndata1,
|
||||
qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5)
|
||||
{
|
||||
Q_D(QmlProfilerDataModel);
|
||||
QString displayName;
|
||||
|
||||
QmlEventTypeData typeData(displayName, location, message, rangeType, detailType,
|
||||
message == QmlDebug::DebugMessage ? QString() : data);
|
||||
QmlEventData eventData = (message == QmlDebug::DebugMessage) ?
|
||||
message == DebugMessage ? QString() : data);
|
||||
QmlEventData eventData = (message == DebugMessage) ?
|
||||
QmlEventData(startTime, duration, -1, data) :
|
||||
QmlEventData(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5);
|
||||
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventlocation.h"
|
||||
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
|
||||
namespace QmlProfiler {
|
||||
@@ -38,18 +39,17 @@ class QMLPROFILER_EXPORT QmlProfilerDataModel : public QObject
|
||||
public:
|
||||
struct QmlEventTypeData {
|
||||
QmlEventTypeData(const QString &displayName = QString(),
|
||||
const QmlDebug::QmlEventLocation &location = QmlDebug::QmlEventLocation(),
|
||||
QmlDebug::Message message = QmlDebug::MaximumMessage,
|
||||
QmlDebug::RangeType rangeType = QmlDebug::MaximumRangeType,
|
||||
const QmlEventLocation &location = QmlEventLocation(),
|
||||
Message message = MaximumMessage, RangeType rangeType = MaximumRangeType,
|
||||
int detailType = -1, const QString &data = QString()) :
|
||||
displayName(displayName), location(location), message(message), rangeType(rangeType),
|
||||
detailType(detailType), data(data)
|
||||
{}
|
||||
|
||||
QString displayName;
|
||||
QmlDebug::QmlEventLocation location;
|
||||
QmlDebug::Message message;
|
||||
QmlDebug::RangeType rangeType;
|
||||
QmlEventLocation location;
|
||||
Message message;
|
||||
RangeType rangeType;
|
||||
int detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType
|
||||
QString data;
|
||||
};
|
||||
@@ -215,9 +215,9 @@ public:
|
||||
int count() const;
|
||||
void clear();
|
||||
bool isEmpty() const;
|
||||
void addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int bindingType,
|
||||
void addQmlEvent(Message message, RangeType rangeType, int bindingType,
|
||||
qint64 startTime, qint64 duration, const QString &data,
|
||||
const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2,
|
||||
const QmlEventLocation &location, qint64 ndata1, qint64 ndata2,
|
||||
qint64 ndata3, qint64 ndata4, qint64 ndata5);
|
||||
qint64 lastTimeMark() const;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
struct PendingEvent {
|
||||
QmlDebug::QmlEventLocation location;
|
||||
QmlEventLocation location;
|
||||
QString localFile;
|
||||
int requestId;
|
||||
};
|
||||
@@ -118,7 +118,7 @@ QmlProfilerDetailsRewriter::~QmlProfilerDetailsRewriter()
|
||||
}
|
||||
|
||||
void QmlProfilerDetailsRewriter::requestDetailsForLocation(int requestId,
|
||||
const QmlDebug::QmlEventLocation &location)
|
||||
const QmlEventLocation &location)
|
||||
{
|
||||
QString localFile;
|
||||
if (!d->m_filesCache.contains(location.filename)) {
|
||||
@@ -157,7 +157,7 @@ void QmlProfilerDetailsRewriter::reloadDocuments()
|
||||
}
|
||||
|
||||
void QmlProfilerDetailsRewriter::rewriteDetailsForLocation(QTextStream &textDoc,
|
||||
QmlJS::Document::Ptr doc, int requestId, const QmlDebug::QmlEventLocation &location)
|
||||
QmlJS::Document::Ptr doc, int requestId, const QmlEventLocation &location)
|
||||
{
|
||||
PropertyVisitor propertyVisitor;
|
||||
QmlJS::AST::Node *node = propertyVisitor(doc->ast(), location.line, location.column);
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "qmlprofilereventlocation.h"
|
||||
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
@@ -45,10 +46,10 @@ public:
|
||||
|
||||
private:
|
||||
void rewriteDetailsForLocation(QTextStream &textDoc, QmlJS::Document::Ptr doc, int requestId,
|
||||
const QmlDebug::QmlEventLocation &location);
|
||||
const QmlEventLocation &location);
|
||||
|
||||
public slots:
|
||||
void requestDetailsForLocation(int requestId, const QmlDebug::QmlEventLocation &location);
|
||||
void requestDetailsForLocation(int requestId, const QmlEventLocation &location);
|
||||
void reloadDocuments();
|
||||
void documentReady(QmlJS::Document::Ptr doc);
|
||||
signals:
|
||||
|
||||
45
src/plugins/qmlprofiler/qmlprofilereventlocation.h
Normal file
45
src/plugins/qmlprofiler/qmlprofilereventlocation.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofiler_global.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
struct QMLPROFILER_EXPORT QmlEventLocation
|
||||
{
|
||||
QmlEventLocation() : line(-1),column(-1) {}
|
||||
QmlEventLocation(const QString &file, int lineNumber, int columnNumber) : filename(file),
|
||||
line(lineNumber), column(columnNumber)
|
||||
{}
|
||||
QString filename;
|
||||
int line;
|
||||
int column;
|
||||
};
|
||||
|
||||
}
|
||||
182
src/plugins/qmlprofiler/qmlprofilereventtypes.h
Normal file
182
src/plugins/qmlprofiler/qmlprofilereventtypes.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
enum Message {
|
||||
Event,
|
||||
RangeStart,
|
||||
RangeData,
|
||||
RangeLocation,
|
||||
RangeEnd,
|
||||
Complete,
|
||||
PixmapCacheEvent,
|
||||
SceneGraphFrame,
|
||||
MemoryAllocation,
|
||||
DebugMessage,
|
||||
|
||||
MaximumMessage
|
||||
};
|
||||
|
||||
enum EventType {
|
||||
FramePaint, // unused
|
||||
Mouse,
|
||||
Key,
|
||||
AnimationFrame, // new Qt5 paint events
|
||||
EndTrace,
|
||||
StartTrace,
|
||||
|
||||
MaximumEventType
|
||||
};
|
||||
|
||||
enum RangeType {
|
||||
Painting, // old Qt4 paint events
|
||||
Compiling,
|
||||
Creating,
|
||||
Binding,
|
||||
HandlingSignal,
|
||||
Javascript,
|
||||
|
||||
MaximumRangeType
|
||||
};
|
||||
|
||||
enum BindingType {
|
||||
QmlBinding,
|
||||
V8Binding,
|
||||
OptimizedBinding,
|
||||
QPainterEvent,
|
||||
|
||||
MaximumBindingType
|
||||
};
|
||||
|
||||
enum PixmapEventType {
|
||||
PixmapSizeKnown,
|
||||
PixmapReferenceCountChanged,
|
||||
PixmapCacheCountChanged,
|
||||
PixmapLoadingStarted,
|
||||
PixmapLoadingFinished,
|
||||
PixmapLoadingError,
|
||||
|
||||
MaximumPixmapEventType
|
||||
};
|
||||
|
||||
enum InputEventType {
|
||||
InputKeyPress,
|
||||
InputKeyRelease,
|
||||
InputKeyUnknown,
|
||||
|
||||
InputMousePress,
|
||||
InputMouseRelease,
|
||||
InputMouseMove,
|
||||
InputMouseDoubleClick,
|
||||
InputMouseWheel,
|
||||
InputMouseUnknown,
|
||||
|
||||
MaximumInputEventType
|
||||
};
|
||||
|
||||
enum SceneGraphFrameType {
|
||||
SceneGraphRendererFrame, // Render Thread
|
||||
SceneGraphAdaptationLayerFrame, // Render Thread
|
||||
SceneGraphContextFrame, // Render Thread
|
||||
SceneGraphRenderLoopFrame, // Render Thread
|
||||
SceneGraphTexturePrepare, // Render Thread
|
||||
SceneGraphTextureDeletion, // Render Thread
|
||||
SceneGraphPolishAndSync, // GUI Thread
|
||||
SceneGraphWindowsRenderShow, // Unused
|
||||
SceneGraphWindowsAnimations, // GUI Thread
|
||||
SceneGraphPolishFrame, // GUI Thread
|
||||
|
||||
MaximumSceneGraphFrameType
|
||||
};
|
||||
|
||||
enum MemoryType {
|
||||
HeapPage,
|
||||
LargeItem,
|
||||
SmallItem,
|
||||
|
||||
MaximumMemoryType
|
||||
};
|
||||
|
||||
enum AnimationThread {
|
||||
GuiThread,
|
||||
RenderThread,
|
||||
|
||||
MaximumAnimationThread
|
||||
};
|
||||
|
||||
enum ProfileFeature {
|
||||
ProfileJavaScript,
|
||||
ProfileMemory,
|
||||
ProfilePixmapCache,
|
||||
ProfileSceneGraph,
|
||||
ProfileAnimations,
|
||||
ProfilePainting,
|
||||
ProfileCompiling,
|
||||
ProfileCreating,
|
||||
ProfileBinding,
|
||||
ProfileHandlingSignal,
|
||||
ProfileInputEvents,
|
||||
ProfileDebugMessages,
|
||||
|
||||
MaximumProfileFeature
|
||||
};
|
||||
|
||||
inline ProfileFeature featureFromRangeType(RangeType range)
|
||||
{
|
||||
switch (range) {
|
||||
case Painting:
|
||||
return ProfilePainting;
|
||||
case Compiling:
|
||||
return ProfileCompiling;
|
||||
case Creating:
|
||||
return ProfileCreating;
|
||||
case Binding:
|
||||
return ProfileBinding;
|
||||
case HandlingSignal:
|
||||
return ProfileHandlingSignal;
|
||||
case Javascript:
|
||||
return ProfileJavaScript;
|
||||
default:
|
||||
return MaximumProfileFeature;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Constants {
|
||||
const int QML_MIN_LEVEL = 1; // Set to 0 to remove the empty line between models in the timeline
|
||||
|
||||
// Shorthand for all QML and JS range features.
|
||||
const quint64 QML_JS_RANGE_FEATURES = (1 << ProfileCompiling) |
|
||||
(1 << ProfileCreating) |
|
||||
(1 << ProfileBinding) |
|
||||
(1 << ProfileHandlingSignal) |
|
||||
(1 << ProfileJavaScript);
|
||||
}
|
||||
|
||||
} // namespace QmlProfiler
|
||||
@@ -55,7 +55,7 @@ static const char *ProfileFeatureNames[] = {
|
||||
QT_TRANSLATE_NOOP("MainView", "Debug Messages")
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(ProfileFeatureNames) == sizeof(char *) * QmlDebug::MaximumProfileFeature);
|
||||
Q_STATIC_ASSERT(sizeof(ProfileFeatureNames) == sizeof(char *) * MaximumProfileFeature);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
QmlProfilerTraceTime::QmlProfilerTraceTime(QObject *parent) :
|
||||
@@ -274,22 +274,15 @@ void QmlProfilerModelManager::setRecordedFeatures(quint64 features)
|
||||
}
|
||||
}
|
||||
|
||||
const char *QmlProfilerModelManager::featureName(QmlDebug::ProfileFeature feature)
|
||||
const char *QmlProfilerModelManager::featureName(ProfileFeature feature)
|
||||
{
|
||||
return ProfileFeatureNames[feature];
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::addQmlEvent(QmlDebug::Message message,
|
||||
QmlDebug::RangeType rangeType,
|
||||
int detailType,
|
||||
qint64 startTime,
|
||||
qint64 length,
|
||||
const QString &data,
|
||||
const QmlDebug::QmlEventLocation &location,
|
||||
qint64 ndata1,
|
||||
qint64 ndata2,
|
||||
qint64 ndata3,
|
||||
qint64 ndata4,
|
||||
void QmlProfilerModelManager::addQmlEvent(Message message, RangeType rangeType, int detailType,
|
||||
qint64 startTime, qint64 length, const QString &data,
|
||||
const QmlEventLocation &location, qint64 ndata1,
|
||||
qint64 ndata2, qint64 ndata3, qint64 ndata4,
|
||||
qint64 ndata5)
|
||||
{
|
||||
// If trace start time was not explicitly set, use the first event
|
||||
@@ -302,11 +295,11 @@ void QmlProfilerModelManager::addQmlEvent(QmlDebug::Message message,
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::addDebugMessage(QtMsgType type, qint64 timestamp, const QString &text,
|
||||
const QmlDebug::QmlEventLocation &location)
|
||||
const QmlEventLocation &location)
|
||||
{
|
||||
if (state() == AcquiringData)
|
||||
d->model->addQmlEvent(QmlDebug::DebugMessage, QmlDebug::MaximumRangeType, type, timestamp,
|
||||
0, text, location, 0, 0, 0, 0, 0);
|
||||
d->model->addQmlEvent(DebugMessage, MaximumRangeType, type, timestamp, 0, text, location, 0,
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::acquiringDone()
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofiler_global.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventlocation.h"
|
||||
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
void acquiringDone();
|
||||
void processingDone();
|
||||
|
||||
static const char *featureName(QmlDebug::ProfileFeature feature);
|
||||
static const char *featureName(ProfileFeature feature);
|
||||
|
||||
signals:
|
||||
void error(const QString &error);
|
||||
@@ -116,7 +116,7 @@ signals:
|
||||
void loadFinished();
|
||||
void saveFinished();
|
||||
|
||||
void requestDetailsForLocation(int eventType, const QmlDebug::QmlEventLocation &location);
|
||||
void requestDetailsForLocation(int eventType, const QmlEventLocation &location);
|
||||
void availableFeaturesChanged(quint64 features);
|
||||
void visibleFeaturesChanged(quint64 features);
|
||||
void recordedFeaturesChanged(quint64 features);
|
||||
@@ -125,12 +125,11 @@ public slots:
|
||||
void clear();
|
||||
|
||||
void prepareForWriting();
|
||||
void addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int bindingType,
|
||||
qint64 startTime, qint64 length, const QString &data,
|
||||
const QmlDebug::QmlEventLocation &location,
|
||||
void addQmlEvent(Message message, RangeType rangeType, int bindingType, qint64 startTime,
|
||||
qint64 length, const QString &data, const QmlEventLocation &location,
|
||||
qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5);
|
||||
void addDebugMessage(QtMsgType type, qint64 timestamp, const QString &text,
|
||||
const QmlDebug::QmlEventLocation &location);
|
||||
const QmlEventLocation &location);
|
||||
|
||||
void save(const QString &filename);
|
||||
void load(const QString &filename);
|
||||
|
||||
@@ -44,10 +44,9 @@ namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
QmlProfilerRangeModel::QmlProfilerRangeModel(QmlProfilerModelManager *manager,
|
||||
QmlDebug::RangeType range, QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, QmlDebug::MaximumMessage, range,
|
||||
QmlDebug::featureFromRangeType(range), parent)
|
||||
QmlProfilerRangeModel::QmlProfilerRangeModel(QmlProfilerModelManager *manager, RangeType range,
|
||||
QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, MaximumMessage, range, featureFromRangeType(range), parent)
|
||||
{
|
||||
m_expandedRowTypes << -1;
|
||||
}
|
||||
@@ -62,7 +61,7 @@ void QmlProfilerRangeModel::clear()
|
||||
|
||||
bool QmlProfilerRangeModel::supportsBindingLoops() const
|
||||
{
|
||||
return rangeType() == QmlDebug::Binding || rangeType() == QmlDebug::HandlingSignal;
|
||||
return rangeType() == Binding || rangeType() == HandlingSignal;
|
||||
}
|
||||
|
||||
void QmlProfilerRangeModel::loadData()
|
||||
@@ -113,7 +112,7 @@ void QmlProfilerRangeModel::computeNestingContracted()
|
||||
int i;
|
||||
int eventCount = count();
|
||||
|
||||
int nestingLevels = QmlDebug::Constants::QML_MIN_LEVEL;
|
||||
int nestingLevels = Constants::QML_MIN_LEVEL;
|
||||
int collapsedRowCount = nestingLevels + 1;
|
||||
QVector<qint64> nestingEndTimes;
|
||||
nestingEndTimes.fill(0, nestingLevels + 1);
|
||||
@@ -128,7 +127,7 @@ void QmlProfilerRangeModel::computeNestingContracted()
|
||||
if (nestingLevels == collapsedRowCount)
|
||||
++collapsedRowCount;
|
||||
} else {
|
||||
while (nestingLevels > QmlDebug::Constants::QML_MIN_LEVEL &&
|
||||
while (nestingLevels > Constants::QML_MIN_LEVEL &&
|
||||
nestingEndTimes[nestingLevels-1] <= st)
|
||||
nestingLevels--;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofilertimelinemodel.h"
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include <QVariantList>
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventlocation.h"
|
||||
|
||||
#include <QVariantList>
|
||||
#include <QColor>
|
||||
|
||||
namespace QmlProfiler {
|
||||
@@ -44,8 +45,8 @@ public:
|
||||
|
||||
struct QmlRangeEventStartInstance {
|
||||
QmlRangeEventStartInstance() :
|
||||
displayRowExpanded(QmlDebug::Constants::QML_MIN_LEVEL),
|
||||
displayRowCollapsed(QmlDebug::Constants::QML_MIN_LEVEL),
|
||||
displayRowExpanded(Constants::QML_MIN_LEVEL),
|
||||
displayRowCollapsed(Constants::QML_MIN_LEVEL),
|
||||
bindingLoopHead(-1) {}
|
||||
|
||||
// not-expanded, per type
|
||||
@@ -54,8 +55,7 @@ public:
|
||||
int bindingLoopHead;
|
||||
};
|
||||
|
||||
QmlProfilerRangeModel(QmlProfilerModelManager *manager, QmlDebug::RangeType range,
|
||||
QObject *parent = 0);
|
||||
QmlProfilerRangeModel(QmlProfilerModelManager *manager, RangeType range, QObject *parent = 0);
|
||||
|
||||
Q_INVOKABLE int expandedRow(int index) const;
|
||||
Q_INVOKABLE int collapsedRow(int index) const;
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
int modelId;
|
||||
|
||||
QList<QmlDebug::RangeType> acceptedTypes;
|
||||
QList<RangeType> acceptedTypes;
|
||||
QSet<int> eventsInBindingLoop;
|
||||
QHash<int, QString> notes;
|
||||
};
|
||||
@@ -73,9 +73,9 @@ QmlProfilerStatisticsModel::QmlProfilerStatisticsModel(QmlProfilerModelManager *
|
||||
// We're iterating twice in loadData.
|
||||
modelManager->setProxyCountWeight(d->modelId, 2);
|
||||
|
||||
d->acceptedTypes << QmlDebug::Compiling << QmlDebug::Creating << QmlDebug::Binding << QmlDebug::HandlingSignal << QmlDebug::Javascript;
|
||||
d->acceptedTypes << Compiling << Creating << Binding << HandlingSignal << Javascript;
|
||||
|
||||
modelManager->announceFeatures(d->modelId, QmlDebug::Constants::QML_JS_RANGE_FEATURES);
|
||||
modelManager->announceFeatures(d->modelId, Constants::QML_JS_RANGE_FEATURES);
|
||||
}
|
||||
|
||||
QmlProfilerStatisticsModel::~QmlProfilerStatisticsModel()
|
||||
@@ -83,7 +83,7 @@ QmlProfilerStatisticsModel::~QmlProfilerStatisticsModel()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QmlProfilerStatisticsModel::setEventTypeAccepted(QmlDebug::RangeType type, bool accepted)
|
||||
void QmlProfilerStatisticsModel::setEventTypeAccepted(RangeType type, bool accepted)
|
||||
{
|
||||
if (accepted && !d->acceptedTypes.contains(type))
|
||||
d->acceptedTypes << type;
|
||||
@@ -91,7 +91,7 @@ void QmlProfilerStatisticsModel::setEventTypeAccepted(QmlDebug::RangeType type,
|
||||
d->acceptedTypes.removeOne(type);
|
||||
}
|
||||
|
||||
bool QmlProfilerStatisticsModel::eventTypeAccepted(QmlDebug::RangeType type) const
|
||||
bool QmlProfilerStatisticsModel::eventTypeAccepted(RangeType type) const
|
||||
{
|
||||
return d->acceptedTypes.contains(type);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ void QmlProfilerStatisticsParentsModel::loadData()
|
||||
|
||||
// for level computation
|
||||
QHash<int, qint64> endtimesPerLevel;
|
||||
int level = QmlDebug::Constants::QML_MIN_LEVEL;
|
||||
int level = Constants::QML_MIN_LEVEL;
|
||||
endtimesPerLevel[0] = 0;
|
||||
|
||||
const QSet<int> &eventsInBindingLoop = m_statisticsModel->eventsInBindingLoop();
|
||||
@@ -375,14 +375,14 @@ void QmlProfilerStatisticsParentsModel::loadData()
|
||||
if (endtimesPerLevel[level] > event.startTime()) {
|
||||
level++;
|
||||
} else {
|
||||
while (level > QmlDebug::Constants::QML_MIN_LEVEL &&
|
||||
while (level > Constants::QML_MIN_LEVEL &&
|
||||
endtimesPerLevel[level-1] <= event.startTime())
|
||||
level--;
|
||||
}
|
||||
endtimesPerLevel[level] = event.startTime() + event.duration();
|
||||
|
||||
int parentTypeIndex = -1;
|
||||
if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
|
||||
if (level > Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
|
||||
parentTypeIndex = lastParent[level-1];
|
||||
|
||||
QmlStatisticsRelativesMap &relativesMap = m_data[event.typeIndex()];
|
||||
@@ -419,7 +419,7 @@ void QmlProfilerStatisticsChildrenModel::loadData()
|
||||
|
||||
// for level computation
|
||||
QHash<int, qint64> endtimesPerLevel;
|
||||
int level = QmlDebug::Constants::QML_MIN_LEVEL;
|
||||
int level = Constants::QML_MIN_LEVEL;
|
||||
endtimesPerLevel[0] = 0;
|
||||
|
||||
const QSet<int> &eventsInBindingLoop = m_statisticsModel->eventsInBindingLoop();
|
||||
@@ -437,7 +437,7 @@ void QmlProfilerStatisticsChildrenModel::loadData()
|
||||
if (endtimesPerLevel[level] > event.startTime()) {
|
||||
level++;
|
||||
} else {
|
||||
while (level > QmlDebug::Constants::QML_MIN_LEVEL &&
|
||||
while (level > Constants::QML_MIN_LEVEL &&
|
||||
endtimesPerLevel[level-1] <= event.startTime())
|
||||
level--;
|
||||
}
|
||||
@@ -445,7 +445,7 @@ void QmlProfilerStatisticsChildrenModel::loadData()
|
||||
|
||||
int parentId = -1;
|
||||
|
||||
if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
|
||||
if (level > Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
|
||||
parentId = lastParent[level-1];
|
||||
|
||||
QmlStatisticsRelativesMap &relativesMap = m_data[parentId];
|
||||
|
||||
@@ -27,11 +27,12 @@
|
||||
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include "qmlprofilernotesmodel.h"
|
||||
#include <QObject>
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventlocation.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
#include <QObject>
|
||||
|
||||
namespace QmlProfiler {
|
||||
class QmlProfilerModelManager;
|
||||
@@ -60,8 +61,8 @@ public:
|
||||
QmlProfilerStatisticsModel(QmlProfilerModelManager *modelManager, QObject *parent = 0);
|
||||
~QmlProfilerStatisticsModel();
|
||||
|
||||
void setEventTypeAccepted(QmlDebug::RangeType type, bool accepted);
|
||||
bool eventTypeAccepted(QmlDebug::RangeType) const;
|
||||
void setEventTypeAccepted(RangeType type, bool accepted);
|
||||
bool eventTypeAccepted(RangeType) const;
|
||||
|
||||
const QHash<int, QmlEventStats> &getData() const;
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const;
|
||||
@@ -136,7 +137,6 @@ public:
|
||||
QmlProfilerStatisticsParentsModel(QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerStatisticsModel *statisticsModel,
|
||||
QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
virtual void loadData();
|
||||
};
|
||||
|
||||
@@ -48,8 +48,6 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <functional>
|
||||
|
||||
using namespace QmlDebug;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
@@ -335,7 +333,7 @@ void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features)
|
||||
for (int i = 0; i < MaximumRangeType; ++i) {
|
||||
RangeType range = static_cast<RangeType>(i);
|
||||
quint64 featureFlag = 1ULL << featureFromRangeType(range);
|
||||
if (QmlDebug::Constants::QML_JS_RANGE_FEATURES & featureFlag)
|
||||
if (Constants::QML_JS_RANGE_FEATURES & featureFlag)
|
||||
d->model->setEventTypeAccepted(range, features & featureFlag);
|
||||
}
|
||||
d->model->limitToRange(d->rangeStart, d->rangeEnd);
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include "qmlprofilerstatisticsmodel.h"
|
||||
#include "qmlprofilerviewmanager.h"
|
||||
#include "qmlprofilereventsview.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
#include <utils/itemviews.h>
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
void copyTableToClipboard() const;
|
||||
void copyRowToClipboard() const;
|
||||
|
||||
static QString nameForType(QmlDebug::RangeType typeNumber);
|
||||
static QString nameForType(RangeType typeNumber);
|
||||
|
||||
int selectedTypeId() const;
|
||||
|
||||
|
||||
@@ -28,10 +28,8 @@
|
||||
namespace QmlProfiler {
|
||||
|
||||
QmlProfilerTimelineModel::QmlProfilerTimelineModel(QmlProfilerModelManager *modelManager,
|
||||
QmlDebug::Message message,
|
||||
QmlDebug::RangeType rangeType,
|
||||
QmlDebug::ProfileFeature mainFeature,
|
||||
QObject *parent) :
|
||||
Message message, RangeType rangeType,
|
||||
ProfileFeature mainFeature, QObject *parent) :
|
||||
TimelineModel(modelManager->registerModelProxy(), parent),
|
||||
m_message(message), m_rangeType(rangeType), m_mainFeature(mainFeature),
|
||||
m_modelManager(modelManager)
|
||||
@@ -44,17 +42,17 @@ QmlProfilerTimelineModel::QmlProfilerTimelineModel(QmlProfilerModelManager *mode
|
||||
announceFeatures(1ULL << m_mainFeature);
|
||||
}
|
||||
|
||||
QmlDebug::RangeType QmlProfilerTimelineModel::rangeType() const
|
||||
RangeType QmlProfilerTimelineModel::rangeType() const
|
||||
{
|
||||
return m_rangeType;
|
||||
}
|
||||
|
||||
QmlDebug::Message QmlProfilerTimelineModel::message() const
|
||||
Message QmlProfilerTimelineModel::message() const
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
|
||||
QmlDebug::ProfileFeature QmlProfilerTimelineModel::mainFeature() const
|
||||
ProfileFeature QmlProfilerTimelineModel::mainFeature() const
|
||||
{
|
||||
return m_mainFeature;
|
||||
}
|
||||
@@ -133,7 +131,7 @@ QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const
|
||||
if (id >= types.length())
|
||||
return result;
|
||||
|
||||
const QmlDebug::QmlEventLocation &location = types.at(id).location;
|
||||
const QmlEventLocation &location = types.at(id).location;
|
||||
|
||||
result.insert(QStringLiteral("file"), location.filename);
|
||||
result.insert(QStringLiteral("line"), location.line);
|
||||
|
||||
@@ -34,20 +34,19 @@ namespace QmlProfiler {
|
||||
|
||||
class QMLPROFILER_EXPORT QmlProfilerTimelineModel : public Timeline::TimelineModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QmlDebug::RangeType rangeType READ rangeType CONSTANT)
|
||||
Q_PROPERTY(QmlDebug::Message message READ message CONSTANT)
|
||||
Q_PROPERTY(RangeType rangeType READ rangeType CONSTANT)
|
||||
Q_PROPERTY(Message message READ message CONSTANT)
|
||||
Q_PROPERTY(QmlProfilerModelManager *modelManager READ modelManager CONSTANT)
|
||||
|
||||
public:
|
||||
QmlProfilerTimelineModel(QmlProfilerModelManager *modelManager,
|
||||
QmlDebug::Message message, QmlDebug::RangeType rangeType,
|
||||
QmlDebug::ProfileFeature mainFeature, QObject *parent);
|
||||
QmlProfilerTimelineModel(QmlProfilerModelManager *modelManager, Message message,
|
||||
RangeType rangeType, ProfileFeature mainFeature, QObject *parent);
|
||||
|
||||
QmlProfilerModelManager *modelManager() const;
|
||||
|
||||
QmlDebug::RangeType rangeType() const;
|
||||
QmlDebug::Message message() const;
|
||||
QmlDebug::ProfileFeature mainFeature() const;
|
||||
RangeType rangeType() const;
|
||||
Message message() const;
|
||||
ProfileFeature mainFeature() const;
|
||||
|
||||
virtual bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
|
||||
bool handlesTypeId(int typeId) const;
|
||||
@@ -66,9 +65,9 @@ protected:
|
||||
void announceFeatures(quint64 features) const;
|
||||
|
||||
private:
|
||||
const QmlDebug::Message m_message;
|
||||
const QmlDebug::RangeType m_rangeType;
|
||||
const QmlDebug::ProfileFeature m_mainFeature;
|
||||
const Message m_message;
|
||||
const RangeType m_rangeType;
|
||||
const ProfileFeature m_mainFeature;
|
||||
QmlProfilerModelManager *const m_modelManager;
|
||||
};
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ using namespace Core::Constants;
|
||||
using namespace Debugger;
|
||||
using namespace Debugger::Constants;
|
||||
using namespace QmlProfiler::Constants;
|
||||
using namespace QmlDebug;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "qmlprofiler_global.h"
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmldebug/qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
#include <debugger/analyzer/analyzerruncontrol.h>
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
void updateRunActions();
|
||||
void clearDisplay();
|
||||
void populateFileFinder(QString projectDirectory = QString(), QString activeSysroot = QString());
|
||||
template<QmlDebug::ProfileFeature feature>
|
||||
template<ProfileFeature feature>
|
||||
void updateFeatures(quint64 features);
|
||||
bool checkForUnsavedNotes();
|
||||
void restoreFeatureVisibility();
|
||||
|
||||
401
src/plugins/qmlprofiler/qmlprofilertraceclient.cpp
Normal file
401
src/plugins/qmlprofiler/qmlprofilertraceclient.cpp
Normal file
@@ -0,0 +1,401 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlprofilertraceclient.h"
|
||||
#include <qmldebug/qmlenginecontrolclient.h>
|
||||
#include <qmldebug/qdebugmessageclient.h>
|
||||
#include <qmldebug/qpacketprotocol.h>
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
class QmlProfilerTraceClientPrivate {
|
||||
public:
|
||||
QmlProfilerTraceClientPrivate(QmlProfilerTraceClient *_q, QmlDebug::QmlDebugConnection *client)
|
||||
: q(_q)
|
||||
, engineControl(client)
|
||||
, inProgressRanges(0)
|
||||
, maximumTime(0)
|
||||
, recording(false)
|
||||
, requestedFeatures(0)
|
||||
, recordedFeatures(0)
|
||||
, flushInterval(0)
|
||||
{
|
||||
::memset(rangeCount, 0, MaximumRangeType * sizeof(int));
|
||||
}
|
||||
|
||||
void sendRecordingStatus(int engineId);
|
||||
bool updateFeatures(ProfileFeature feature);
|
||||
|
||||
QmlProfilerTraceClient *q;
|
||||
QmlDebug::QmlEngineControlClient engineControl;
|
||||
QScopedPointer<QmlDebug::QDebugMessageClient> messageClient;
|
||||
qint64 inProgressRanges;
|
||||
QStack<qint64> rangeStartTimes[MaximumRangeType];
|
||||
QStack<QString> rangeDatas[MaximumRangeType];
|
||||
QStack<QmlEventLocation> rangeLocations[MaximumRangeType];
|
||||
QStack<BindingType> bindingTypes;
|
||||
int rangeCount[MaximumRangeType];
|
||||
qint64 maximumTime;
|
||||
bool recording;
|
||||
quint64 requestedFeatures;
|
||||
quint64 recordedFeatures;
|
||||
quint32 flushInterval;
|
||||
};
|
||||
|
||||
} // namespace QmlProfiler
|
||||
|
||||
using namespace QmlProfiler;
|
||||
|
||||
void QmlProfilerTraceClientPrivate::sendRecordingStatus(int engineId)
|
||||
{
|
||||
QmlDebug::QPacket stream(q->connection()->currentDataStreamVersion());
|
||||
stream << recording << engineId; // engineId -1 is OK. It means "all of them"
|
||||
if (recording)
|
||||
stream << requestedFeatures << flushInterval;
|
||||
q->sendMessage(stream.data());
|
||||
}
|
||||
|
||||
QmlProfilerTraceClient::QmlProfilerTraceClient(QmlDebug::QmlDebugConnection *client,
|
||||
quint64 features)
|
||||
: QmlDebugClient(QLatin1String("CanvasFrameRate"), client)
|
||||
, d(new QmlProfilerTraceClientPrivate(this, client))
|
||||
{
|
||||
setRequestedFeatures(features);
|
||||
connect(&d->engineControl, &QmlDebug::QmlEngineControlClient::engineAboutToBeAdded,
|
||||
this, &QmlProfilerTraceClient::newEngine);
|
||||
}
|
||||
|
||||
QmlProfilerTraceClient::~QmlProfilerTraceClient()
|
||||
{
|
||||
//Disable profiling if started by client
|
||||
//Profiling data will be lost!!
|
||||
if (isRecording())
|
||||
setRecording(false);
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::clearData()
|
||||
{
|
||||
::memset(d->rangeCount, 0, MaximumRangeType * sizeof(int));
|
||||
for (int eventType = 0; eventType < MaximumRangeType; eventType++) {
|
||||
d->rangeDatas[eventType].clear();
|
||||
d->rangeLocations[eventType].clear();
|
||||
d->rangeStartTimes[eventType].clear();
|
||||
}
|
||||
d->bindingTypes.clear();
|
||||
if (d->recordedFeatures != 0) {
|
||||
d->recordedFeatures = 0;
|
||||
emit recordedFeaturesChanged(0);
|
||||
}
|
||||
emit cleared();
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::sendRecordingStatus(int engineId)
|
||||
{
|
||||
d->sendRecordingStatus(engineId);
|
||||
}
|
||||
|
||||
bool QmlProfilerTraceClient::isRecording() const
|
||||
{
|
||||
return d->recording;
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::setRecording(bool v)
|
||||
{
|
||||
if (v == d->recording)
|
||||
return;
|
||||
|
||||
d->recording = v;
|
||||
|
||||
if (state() == Enabled)
|
||||
sendRecordingStatus();
|
||||
|
||||
emit recordingChanged(v);
|
||||
}
|
||||
|
||||
quint64 QmlProfilerTraceClient::recordedFeatures() const
|
||||
{
|
||||
return d->recordedFeatures;
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::setRequestedFeatures(quint64 features)
|
||||
{
|
||||
d->requestedFeatures = features;
|
||||
if (features & static_cast<quint64>(1) << ProfileDebugMessages) {
|
||||
d->messageClient.reset(new QmlDebug::QDebugMessageClient(connection()));
|
||||
connect(d->messageClient.data(), &QmlDebug::QDebugMessageClient::message, this,
|
||||
[this](QtMsgType type, const QString &text,
|
||||
const QmlDebug::QDebugContextInfo &context)
|
||||
{
|
||||
d->updateFeatures(ProfileDebugMessages);
|
||||
emit debugMessage(type, context.timestamp, text,
|
||||
QmlEventLocation(context.file, context.line, 1));
|
||||
});
|
||||
} else {
|
||||
d->messageClient.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::setFlushInterval(quint32 flushInterval)
|
||||
{
|
||||
d->flushInterval = flushInterval;
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::setRecordingFromServer(bool v)
|
||||
{
|
||||
if (v == d->recording)
|
||||
return;
|
||||
d->recording = v;
|
||||
emit recordingChanged(v);
|
||||
}
|
||||
|
||||
bool QmlProfilerTraceClientPrivate::updateFeatures(ProfileFeature feature)
|
||||
{
|
||||
quint64 flag = 1ULL << feature;
|
||||
if (!(requestedFeatures & flag))
|
||||
return false;
|
||||
if (!(recordedFeatures & flag)) {
|
||||
recordedFeatures |= flag;
|
||||
emit q->recordedFeaturesChanged(recordedFeatures);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::stateChanged(State status)
|
||||
{
|
||||
if (status == Enabled)
|
||||
sendRecordingStatus(-1);
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
|
||||
{
|
||||
QmlDebug::QPacket stream(connection()->currentDataStreamVersion(), data);
|
||||
|
||||
qint64 time;
|
||||
int messageType;
|
||||
int subtype;
|
||||
|
||||
stream >> time >> messageType;
|
||||
if (!stream.atEnd())
|
||||
stream >> subtype;
|
||||
else
|
||||
subtype = -1;
|
||||
|
||||
switch (messageType) {
|
||||
case Event: {
|
||||
switch (subtype) {
|
||||
case StartTrace: {
|
||||
if (!d->recording)
|
||||
setRecordingFromServer(true);
|
||||
QList<int> engineIds;
|
||||
while (!stream.atEnd()) {
|
||||
int id;
|
||||
stream >> id;
|
||||
engineIds << id;
|
||||
}
|
||||
emit traceStarted(time, engineIds);
|
||||
d->maximumTime = time;
|
||||
break;
|
||||
}
|
||||
case EndTrace: {
|
||||
QList<int> engineIds;
|
||||
while (!stream.atEnd()) {
|
||||
int id;
|
||||
stream >> id;
|
||||
engineIds << id;
|
||||
}
|
||||
emit traceFinished(time, engineIds);
|
||||
d->maximumTime = time;
|
||||
d->maximumTime = qMax(time, d->maximumTime);
|
||||
break;
|
||||
}
|
||||
case AnimationFrame: {
|
||||
if (!d->updateFeatures(ProfileAnimations))
|
||||
break;
|
||||
int frameRate, animationCount;
|
||||
int threadId;
|
||||
stream >> frameRate >> animationCount;
|
||||
if (!stream.atEnd())
|
||||
stream >> threadId;
|
||||
else
|
||||
threadId = 0;
|
||||
|
||||
emit rangedEvent(Event, MaximumRangeType, AnimationFrame, time, 0, QString(),
|
||||
QmlEventLocation(), frameRate, animationCount, threadId,
|
||||
0, 0);
|
||||
d->maximumTime = qMax(time, d->maximumTime);
|
||||
break;
|
||||
}
|
||||
case Key:
|
||||
case Mouse:
|
||||
if (!d->updateFeatures(ProfileInputEvents))
|
||||
break;
|
||||
int inputType = (subtype == Key ? InputKeyUnknown : InputMouseUnknown);
|
||||
if (!stream.atEnd())
|
||||
stream >> inputType;
|
||||
int a = -1;
|
||||
if (!stream.atEnd())
|
||||
stream >> a;
|
||||
int b = -1;
|
||||
if (!stream.atEnd())
|
||||
stream >> b;
|
||||
|
||||
emit rangedEvent(Event, MaximumRangeType, subtype, time, 0, QString(),
|
||||
QmlEventLocation(), inputType, a, b, 0, 0);
|
||||
d->maximumTime = qMax(time, d->maximumTime);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case Complete:
|
||||
emit complete(d->maximumTime);
|
||||
setRecordingFromServer(false);
|
||||
break;
|
||||
case SceneGraphFrame: {
|
||||
if (!d->updateFeatures(ProfileSceneGraph))
|
||||
break;
|
||||
|
||||
int count = 0;
|
||||
qint64 params[5];
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
stream >> params[count++];
|
||||
}
|
||||
while (count<5)
|
||||
params[count++] = 0;
|
||||
emit rangedEvent(SceneGraphFrame, MaximumRangeType, subtype,time, 0,
|
||||
QString(), QmlEventLocation(), params[0], params[1],
|
||||
params[2], params[3], params[4]);
|
||||
break;
|
||||
}
|
||||
case PixmapCacheEvent: {
|
||||
if (!d->updateFeatures(ProfilePixmapCache))
|
||||
break;
|
||||
int width = 0, height = 0, refcount = 0;
|
||||
QString pixUrl;
|
||||
stream >> pixUrl;
|
||||
if (subtype == (int)PixmapReferenceCountChanged || subtype == (int)PixmapCacheCountChanged) {
|
||||
stream >> refcount;
|
||||
} else if (subtype == (int)PixmapSizeKnown) {
|
||||
stream >> width >> height;
|
||||
refcount = 1;
|
||||
}
|
||||
emit rangedEvent(PixmapCacheEvent, MaximumRangeType, subtype, time, 0,
|
||||
QString(), QmlEventLocation(pixUrl,0,0), width, height,
|
||||
refcount, 0, 0);
|
||||
d->maximumTime = qMax(time, d->maximumTime);
|
||||
break;
|
||||
}
|
||||
case MemoryAllocation: {
|
||||
if (!d->updateFeatures(ProfileMemory))
|
||||
break;
|
||||
|
||||
qint64 delta;
|
||||
stream >> delta;
|
||||
emit rangedEvent(MemoryAllocation, MaximumRangeType, subtype, time, 0,
|
||||
QString(), QmlEventLocation(), delta, 0, 0, 0, 0);
|
||||
d->maximumTime = qMax(time, d->maximumTime);
|
||||
break;
|
||||
}
|
||||
case RangeStart: {
|
||||
if (!d->updateFeatures(featureFromRangeType(static_cast<RangeType>(subtype))))
|
||||
break;
|
||||
d->rangeStartTimes[subtype].push(time);
|
||||
d->inProgressRanges |= (static_cast<qint64>(1) << subtype);
|
||||
++d->rangeCount[subtype];
|
||||
|
||||
// read binding type
|
||||
if ((RangeType)subtype == Binding) {
|
||||
int bindingType = (int)QmlBinding;
|
||||
if (!stream.atEnd())
|
||||
stream >> bindingType;
|
||||
d->bindingTypes.push((BindingType)bindingType);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RangeData: {
|
||||
if (!d->updateFeatures(featureFromRangeType(static_cast<RangeType>(subtype))))
|
||||
break;
|
||||
QString data;
|
||||
stream >> data;
|
||||
|
||||
int count = d->rangeCount[subtype];
|
||||
if (count > 0) {
|
||||
while (d->rangeDatas[subtype].count() < count)
|
||||
d->rangeDatas[subtype].push(QString());
|
||||
d->rangeDatas[subtype][count-1] = data;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RangeLocation: {
|
||||
if (!d->updateFeatures(featureFromRangeType(static_cast<RangeType>(subtype))))
|
||||
break;
|
||||
QString fileName;
|
||||
int line;
|
||||
int column = -1;
|
||||
stream >> fileName >> line;
|
||||
|
||||
if (!stream.atEnd())
|
||||
stream >> column;
|
||||
|
||||
if (d->rangeCount[subtype] > 0)
|
||||
d->rangeLocations[subtype].push(QmlEventLocation(fileName, line, column));
|
||||
break;
|
||||
}
|
||||
case RangeEnd: {
|
||||
if (!d->updateFeatures(featureFromRangeType(static_cast<RangeType>(subtype))))
|
||||
break;
|
||||
if (d->rangeCount[subtype] == 0)
|
||||
break;
|
||||
--d->rangeCount[subtype];
|
||||
if (d->inProgressRanges & (static_cast<qint64>(1) << subtype))
|
||||
d->inProgressRanges &= ~(static_cast<qint64>(1) << subtype);
|
||||
|
||||
d->maximumTime = qMax(time, d->maximumTime);
|
||||
QString data = d->rangeDatas[subtype].count() ? d->rangeDatas[subtype].pop() : QString();
|
||||
QmlEventLocation location = d->rangeLocations[subtype].count() ? d->rangeLocations[subtype].pop() : QmlEventLocation();
|
||||
|
||||
qint64 startTime = d->rangeStartTimes[subtype].pop();
|
||||
BindingType bindingType = QmlBinding;
|
||||
if ((RangeType)subtype == Binding)
|
||||
bindingType = d->bindingTypes.pop();
|
||||
if ((RangeType)subtype == Painting)
|
||||
bindingType = QPainterEvent;
|
||||
emit rangedEvent(MaximumMessage, (RangeType)subtype, bindingType, startTime,
|
||||
time - startTime, data, location, 0, 0, 0, 0, 0);
|
||||
if (d->rangeCount[subtype] == 0) {
|
||||
int count = d->rangeDatas[subtype].count() +
|
||||
d->rangeStartTimes[subtype].count() +
|
||||
d->rangeLocations[subtype].count();
|
||||
if (count != 0)
|
||||
qWarning() << "incorrectly nested data";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
87
src/plugins/qmlprofiler/qmlprofilertraceclient.h
Normal file
87
src/plugins/qmlprofiler/qmlprofilertraceclient.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventlocation.h"
|
||||
#include "qmlprofiler_global.h"
|
||||
|
||||
#include <qmldebug/qmldebugclient.h>
|
||||
|
||||
#include <QStack>
|
||||
#include <QStringList>
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
class QMLDEBUG_EXPORT QmlProfilerTraceClient : public QmlDebug::QmlDebugClient
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
|
||||
|
||||
// don't hide by signal
|
||||
using QObject::event;
|
||||
|
||||
public:
|
||||
QmlProfilerTraceClient(QmlDebug::QmlDebugConnection *client, quint64 features);
|
||||
~QmlProfilerTraceClient();
|
||||
|
||||
bool isRecording() const;
|
||||
void setRecording(bool);
|
||||
quint64 recordedFeatures() const;
|
||||
|
||||
public slots:
|
||||
void clearData();
|
||||
void sendRecordingStatus(int engineId = -1);
|
||||
void setRequestedFeatures(quint64 features);
|
||||
void setFlushInterval(quint32 flushInterval);
|
||||
|
||||
signals:
|
||||
void complete(qint64 maximumTime);
|
||||
void traceFinished(qint64 time, const QList<int> &engineIds);
|
||||
void traceStarted(qint64 time, const QList<int> &engineIds);
|
||||
void rangedEvent(Message, RangeType, int detailType, qint64 startTime, qint64 length,
|
||||
const QString &data, const QmlEventLocation &location, qint64 param1,
|
||||
qint64 param2, qint64 param3, qint64 param4, qint64 param5);
|
||||
void debugMessage(QtMsgType type, qint64 timestamp, const QString &text,
|
||||
const QmlEventLocation &location);
|
||||
void recordingChanged(bool arg);
|
||||
void recordedFeaturesChanged(quint64 features);
|
||||
void newEngine(int engineId);
|
||||
|
||||
void cleared();
|
||||
|
||||
protected:
|
||||
virtual void stateChanged(State status);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
void setRecordingFromServer(bool);
|
||||
|
||||
private:
|
||||
class QmlProfilerTraceClientPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace QmlProfiler
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "qmlprofilertracefile.h"
|
||||
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QIODevice>
|
||||
@@ -33,9 +34,8 @@
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QDebug>
|
||||
|
||||
// import QmlEventType, QmlBindingType enums, QmlEventLocation
|
||||
using namespace QmlDebug;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
const char PROFILER_FILE_VERSION[] = "1.02";
|
||||
|
||||
@@ -48,7 +48,7 @@ static const char *RANGE_TYPE_STRINGS[] = {
|
||||
"Javascript"
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(RANGE_TYPE_STRINGS) == QmlDebug::MaximumRangeType * sizeof(const char *));
|
||||
Q_STATIC_ASSERT(sizeof(RANGE_TYPE_STRINGS) == MaximumRangeType * sizeof(const char *));
|
||||
|
||||
static const char *MESSAGE_STRINGS[] = {
|
||||
// So far only pixmap and scenegraph are used. The others are padding.
|
||||
@@ -64,7 +64,7 @@ static const char *MESSAGE_STRINGS[] = {
|
||||
"DebugMessage"
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == QmlDebug::MaximumMessage * sizeof(const char *));
|
||||
Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == MaximumMessage * sizeof(const char *));
|
||||
|
||||
#define _(X) QLatin1String(X)
|
||||
|
||||
@@ -72,9 +72,6 @@ Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == QmlDebug::MaximumMessage * sizeof(con
|
||||
// "be strict in your output but tolerant in your inputs"
|
||||
//
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
static QPair<Message, RangeType> qmlTypeAsEnum(const QString &typeString)
|
||||
{
|
||||
QPair<Message, RangeType> ret(MaximumMessage, MaximumRangeType);
|
||||
@@ -195,7 +192,7 @@ quint64 QmlProfilerFileReader::loadedFeatures() const
|
||||
return m_loadedFeatures;
|
||||
}
|
||||
|
||||
QmlDebug::ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTypeData &event) {
|
||||
ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTypeData &event) {
|
||||
if (event.rangeType < MaximumRangeType)
|
||||
return featureFromRangeType(event.rangeType);
|
||||
|
||||
|
||||
@@ -25,16 +25,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qmlprofilereventlocation.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
|
||||
#include <QFutureInterface>
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QIODevice)
|
||||
QT_FORWARD_DECLARE_CLASS(QXmlStreamReader)
|
||||
|
||||
|
||||
@@ -68,8 +68,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
using namespace QmlDebug;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "scenegraphtimelinemodel.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmldebug/qmlprofilereventtypes.h"
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -75,8 +75,7 @@ Q_STATIC_ASSERT(sizeof(StageLabels) ==
|
||||
|
||||
SceneGraphTimelineModel::SceneGraphTimelineModel(QmlProfilerModelManager *manager,
|
||||
QObject *parent) :
|
||||
QmlProfilerTimelineModel(manager, QmlDebug::SceneGraphFrame, QmlDebug::MaximumRangeType,
|
||||
QmlDebug::ProfileSceneGraph, parent)
|
||||
QmlProfilerTimelineModel(manager, SceneGraphFrame, MaximumRangeType, ProfileSceneGraph, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -145,8 +144,8 @@ void SceneGraphTimelineModel::loadData()
|
||||
if (!accepted(type))
|
||||
continue;
|
||||
|
||||
switch ((QmlDebug::SceneGraphFrameType)type.detailType) {
|
||||
case QmlDebug::SceneGraphRendererFrame: {
|
||||
switch ((SceneGraphFrameType)type.detailType) {
|
||||
case SceneGraphRendererFrame: {
|
||||
// Breakdown of render times. We repeat "render" here as "net" render time. It would
|
||||
// look incomplete if that was left out as the printf profiler lists it, too, and people
|
||||
// are apparently comparing that. Unfortunately it is somewhat redundant as the other
|
||||
@@ -159,19 +158,19 @@ void SceneGraphTimelineModel::loadData()
|
||||
insert(startTime, event.numericData(3), event.typeIndex(), RenderRender);
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphAdaptationLayerFrame: {
|
||||
case SceneGraphAdaptationLayerFrame: {
|
||||
qint64 startTime = event.startTime() - event.numericData(1) - event.numericData(2);
|
||||
startTime += insert(startTime, event.numericData(1), event.typeIndex(), GlyphRender,
|
||||
event.numericData(0));
|
||||
insert(startTime, event.numericData(2), event.typeIndex(), GlyphStore, event.numericData(0));
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphContextFrame: {
|
||||
case SceneGraphContextFrame: {
|
||||
insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(),
|
||||
Material);
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphRenderLoopFrame: {
|
||||
case SceneGraphRenderLoopFrame: {
|
||||
qint64 startTime = event.startTime() - event.numericData(0) - event.numericData(1) -
|
||||
event.numericData(2);
|
||||
startTime += insert(startTime, event.numericData(0), event.typeIndex(),
|
||||
@@ -181,7 +180,7 @@ void SceneGraphTimelineModel::loadData()
|
||||
insert(startTime, event.numericData(2), event.typeIndex(), Swap);
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphTexturePrepare: {
|
||||
case SceneGraphTexturePrepare: {
|
||||
qint64 startTime = event.startTime() - event.numericData(0) - event.numericData(1) -
|
||||
event.numericData(2) - event.numericData(3) - event.numericData(4);
|
||||
startTime += insert(startTime, event.numericData(0), event.typeIndex(), TextureBind);
|
||||
@@ -191,12 +190,12 @@ void SceneGraphTimelineModel::loadData()
|
||||
insert(startTime, event.numericData(4), event.typeIndex(), TextureMipmap);
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphTextureDeletion: {
|
||||
case SceneGraphTextureDeletion: {
|
||||
insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(),
|
||||
TextureDeletion);
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphPolishAndSync: {
|
||||
case SceneGraphPolishAndSync: {
|
||||
qint64 startTime = event.startTime() - event.numericData(0) - event.numericData(1) -
|
||||
event.numericData(2) - event.numericData(3);
|
||||
|
||||
@@ -206,13 +205,13 @@ void SceneGraphTimelineModel::loadData()
|
||||
insert(startTime, event.numericData(3), event.typeIndex(), Animations);
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphWindowsAnimations: {
|
||||
case SceneGraphWindowsAnimations: {
|
||||
// GUI thread, separate animations stage
|
||||
insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(),
|
||||
Animations);
|
||||
break;
|
||||
}
|
||||
case QmlDebug::SceneGraphPolishFrame: {
|
||||
case SceneGraphPolishFrame: {
|
||||
// GUI thread, separate polish stage
|
||||
insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(),
|
||||
Polish);
|
||||
|
||||
Reference in New Issue
Block a user