QmlProfiler: Fix the naming scheme for events and event types

Move them out of the QmlProfilerDataModel class, drop the "Data"
suffix, and rename symbols that refer to them in order to call them by
their names.

Change-Id: I41151359921b325edb79111371083c4185bd148b
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-04-26 11:50:59 +02:00
parent 08f807a134
commit a955537132
28 changed files with 540 additions and 452 deletions

View File

@@ -28,7 +28,7 @@
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
bool DebugMessagesModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const bool DebugMessagesModel::accepted(const QmlEventType &event) const
{ {
return event.message == DebugMessage; return event.message == DebugMessage;
} }
@@ -78,8 +78,7 @@ QVariantList DebugMessagesModel::labels() const
QVariantMap DebugMessagesModel::details(int index) const QVariantMap DebugMessagesModel::details(int index) const
{ {
const QmlProfilerDataModel::QmlEventTypeData &type = const QmlEventType &type = modelManager()->qmlModel()->eventTypes()[m_data[index].typeId];
modelManager()->qmlModel()->getEventTypes()[m_data[index].typeId];
QVariantMap result; QVariantMap result;
result.insert(QLatin1String("displayName"), messageType(type.detailType)); result.insert(QLatin1String("displayName"), messageType(type.detailType));
@@ -106,10 +105,10 @@ void DebugMessagesModel::loadData()
if (simpleModel->isEmpty()) if (simpleModel->isEmpty())
return; return;
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes(); const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { foreach (const QmlEvent &event, simpleModel->events()) {
const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type) || event.startTime() < 0) if (!accepted(type) || event.startTime() < 0)
continue; continue;
@@ -117,7 +116,7 @@ void DebugMessagesModel::loadData()
MessageData(event.stringData(), event.typeIndex())); MessageData(event.stringData(), event.typeIndex()));
if (type.detailType > m_maximumMsgType) if (type.detailType > m_maximumMsgType)
m_maximumMsgType = event.typeIndex(); m_maximumMsgType = event.typeIndex();
updateProgress(count(), simpleModel->getEvents().count()); updateProgress(count(), simpleModel->events().count());
} }
setCollapsedRowCount(2); setCollapsedRowCount(2);
setExpandedRowCount(m_maximumMsgType + 2); setExpandedRowCount(m_maximumMsgType + 2);

View File

@@ -35,7 +35,7 @@ class DebugMessagesModel : public QmlProfilerTimelineModel
Q_OBJECT Q_OBJECT
protected: protected:
bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const override; bool accepted(const QmlEventType &event) const override;
public: public:
DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent = 0); DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent = 0);

View File

@@ -102,20 +102,18 @@ void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd)
beginResetModel(); beginResetModel();
clear(); clear();
const QVector<QmlProfilerDataModel::QmlEventData> &eventList const QVector<QmlEvent> &eventList = m_modelManager->qmlModel()->events();
= m_modelManager->qmlModel()->getEvents(); const QVector<QmlEventType> &typesList = m_modelManager->qmlModel()->eventTypes();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typesList
= m_modelManager->qmlModel()->getEventTypes();
// used by binding loop detection // used by binding loop detection
QStack<const QmlProfilerDataModel::QmlEventData *> callStack; QStack<const QmlEvent *> callStack;
callStack.append(0); callStack.append(0);
FlameGraphData *stackTop = &m_stackBottom; FlameGraphData *stackTop = &m_stackBottom;
for (int i = 0; i < eventList.size(); ++i) { for (int i = 0; i < eventList.size(); ++i) {
const QmlProfilerDataModel::QmlEventData *event = &eventList[i]; const QmlEvent *event = &eventList[i];
int typeIndex = event->typeIndex(); int typeIndex = event->typeIndex();
const QmlProfilerDataModel::QmlEventTypeData *type = &typesList[typeIndex]; const QmlEventType *type = &typesList[typeIndex];
if (!m_acceptedTypes.contains(type->rangeType)) if (!m_acceptedTypes.contains(type->rangeType))
continue; continue;
@@ -126,7 +124,7 @@ void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd)
continue; continue;
} }
const QmlProfilerDataModel::QmlEventData *potentialParent = callStack.top(); const QmlEvent *potentialParent = callStack.top();
while (potentialParent && while (potentialParent &&
potentialParent->startTime() + potentialParent->duration() <= event->startTime()) { potentialParent->startTime() + potentialParent->duration() <= event->startTime()) {
callStack.pop(); callStack.pop();
@@ -187,9 +185,8 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const
} }
if (stats.typeIndex != -1) { if (stats.typeIndex != -1) {
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = const QVector<QmlEventType> &typeList = m_modelManager->qmlModel()->eventTypes();
m_modelManager->qmlModel()->getEventTypes(); const QmlEventType &type = typeList[stats.typeIndex];
const QmlProfilerDataModel::QmlEventTypeData &type = typeList[stats.typeIndex];
switch (role) { switch (role) {
case FilenameRole: return type.location.filename; case FilenameRole: return type.location.filename;
@@ -216,7 +213,7 @@ FlameGraphData::~FlameGraphData()
} }
FlameGraphData *FlameGraphModel::pushChild( FlameGraphData *FlameGraphModel::pushChild(
FlameGraphData *parent, const QmlProfilerDataModel::QmlEventData *data) FlameGraphData *parent, const QmlEvent *data)
{ {
foreach (FlameGraphData *child, parent->children) { foreach (FlameGraphData *child, parent->children) {
if (child->typeIndex == data->typeIndex()) { if (child->typeIndex == data->typeIndex()) {

View File

@@ -91,8 +91,7 @@ private:
QVariant lookup(const FlameGraphData &data, int role) const; QVariant lookup(const FlameGraphData &data, int role) const;
void clear(); void clear();
FlameGraphData *pushChild(FlameGraphData *parent, FlameGraphData *pushChild(FlameGraphData *parent, const QmlEvent *data);
const QmlProfilerDataModel::QmlEventData *data);
int m_selectedTypeIndex; int m_selectedTypeIndex;
FlameGraphData m_stackBottom; FlameGraphData m_stackBottom;

View File

@@ -146,9 +146,9 @@ void InputEventsModel::loadData()
if (simpleModel->isEmpty()) if (simpleModel->isEmpty())
return; return;
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes(); const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { foreach (const QmlEvent &event, simpleModel->events()) {
const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type)) if (!accepted(type))
continue; continue;
@@ -162,7 +162,7 @@ void InputEventsModel::loadData()
} else if (m_keyTypeId == -1) { } else if (m_keyTypeId == -1) {
m_keyTypeId = event.typeIndex(); m_keyTypeId = event.typeIndex();
} }
updateProgress(count(), simpleModel->getEvents().count()); updateProgress(count(), simpleModel->events().count());
} }
setCollapsedRowCount(2); setCollapsedRowCount(2);
setExpandedRowCount(3); setExpandedRowCount(3);
@@ -176,7 +176,7 @@ void InputEventsModel::clear()
QmlProfilerTimelineModel::clear(); QmlProfilerTimelineModel::clear();
} }
bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const bool InputEventsModel::accepted(const QmlEventType &event) const
{ {
return QmlProfilerTimelineModel::accepted(event) && return QmlProfilerTimelineModel::accepted(event) &&
(event.detailType == Mouse || event.detailType == Key); (event.detailType == Mouse || event.detailType == Key);

View File

@@ -35,7 +35,7 @@ class InputEventsModel : public QmlProfilerTimelineModel
Q_OBJECT Q_OBJECT
protected: protected:
bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; bool accepted(const QmlEventType &event) const;
public: public:
struct InputEvent { struct InputEvent {

View File

@@ -82,7 +82,7 @@ QVariantMap MemoryUsageModel::location(int index) const
int originType = m_data[index].originTypeIndex; int originType = m_data[index].originTypeIndex;
if (originType > -1) { if (originType > -1) {
const QmlEventLocation &location = const QmlEventLocation &location =
modelManager()->qmlModel()->getEventTypes().at(originType).location; modelManager()->qmlModel()->eventTypes().at(originType).location;
result.insert(file, location.filename); result.insert(file, location.filename);
result.insert(line, location.line); result.insert(line, location.line);
@@ -132,7 +132,7 @@ QVariantMap MemoryUsageModel::details(int index) const
if (ev->originTypeIndex != -1) { if (ev->originTypeIndex != -1) {
result.insert(tr("Location"), result.insert(tr("Location"),
modelManager()->qmlModel()->getEventTypes().at(ev->originTypeIndex).displayName); modelManager()->qmlModel()->eventTypes().at(ev->originTypeIndex).displayName);
} }
return result; return result;
} }
@@ -159,9 +159,9 @@ void MemoryUsageModel::loadData()
QStack<RangeStackFrame> rangeStack; QStack<RangeStackFrame> rangeStack;
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes(); const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { foreach (const QmlEvent &event, simpleModel->events()) {
const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; const QmlEventType &type = types[event.typeIndex()];
while (!rangeStack.empty() && rangeStack.top().endTime < event.startTime()) while (!rangeStack.empty() && rangeStack.top().endTime < event.startTime())
rangeStack.pop(); rangeStack.pop();
if (!accepted(type)) { if (!accepted(type)) {
@@ -218,7 +218,7 @@ void MemoryUsageModel::loadData()
} }
} }
updateProgress(count(), simpleModel->getEvents().count()); updateProgress(count(), simpleModel->events().count());
} }
if (currentJSHeapIndex != -1) if (currentJSHeapIndex != -1)

View File

@@ -174,9 +174,9 @@ void PixmapCacheModel::loadData()
int lastCacheSizeEvent = -1; int lastCacheSizeEvent = -1;
int cumulatedCount = 0; int cumulatedCount = 0;
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes(); const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { foreach (const QmlEvent &event, simpleModel->events()) {
const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type)) if (!accepted(type))
continue; continue;
@@ -398,7 +398,7 @@ void PixmapCacheModel::loadData()
break; break;
} }
updateProgress(count(), 2 * simpleModel->getEvents().count()); updateProgress(count(), 2 * simpleModel->events().count());
} }
if (lastCacheSizeEvent != -1) if (lastCacheSizeEvent != -1)

View File

@@ -0,0 +1,168 @@
/****************************************************************************
**
** 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 <QString>
namespace QmlProfiler {
struct QmlEvent {
QmlEvent(qint64 startTime = -1, qint64 duration = -1, int typeIndex = -1,
qint64 num0 = 0, qint64 num1 = 0, qint64 num2 = 0, qint64 num3 = 0,
qint64 num4 = 0) :
m_startTime(startTime), m_duration(duration), m_dataType(NumericData),
m_typeIndex(typeIndex)
{
m_numericData[0] = num0;
m_numericData[1] = num1;
m_numericData[2] = num2;
m_numericData[3] = num3;
m_numericData[4] = num4;
}
QmlEvent(qint64 startTime, qint64 duration, int typeIndex, const QString &data)
: m_startTime(startTime), m_duration(duration), m_typeIndex(typeIndex)
{
assignStringData(data);
}
QmlEvent(const QmlEvent &other) :
m_startTime(other.m_startTime), m_duration(other.m_duration),
m_dataType(other.m_dataType), m_typeIndex(other.m_typeIndex)
{
assignData(other);
}
QmlEvent &operator=(const QmlEvent &other)
{
if (this != &other) {
if (m_dataType == StringData)
delete m_stringData;
m_startTime = other.m_startTime;
m_duration = other.m_duration;
m_typeIndex = other.m_typeIndex;
m_dataType = other.m_dataType;
assignData(other);
}
return *this;
}
~QmlEvent()
{
if (m_dataType == StringData)
delete m_stringData;
}
qint64 startTime() const { return m_startTime; }
void setStartTime(qint64 startTime) { m_startTime = startTime; }
qint64 duration() const { return m_duration; }
void setDuration(qint64 duration) { m_duration = duration; }
int typeIndex() const { return m_typeIndex; }
void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; }
qint64 numericData(int i) const { return m_dataType == NumericData ? m_numericData[i] : 0; }
void setNumericData(int i, qint64 data)
{
if (m_dataType == StringData)
delete m_stringData;
m_dataType = NumericData;
m_numericData[i] = data;
}
QString stringData() const
{
switch (m_dataType) {
case NumericData: return QString();
case StringData: return *m_stringData;
default: return QString::fromUtf8(m_characterData, m_characterDataLength);
}
}
void setStringData(const QString &data)
{
if (m_dataType == StringData)
delete m_stringData;
assignStringData(data);
}
bool isValid() const
{
return m_startTime != -1;
}
private:
static const quint8 StringData = 254;
static const quint8 NumericData = 255;
qint64 m_startTime;
qint64 m_duration;
union {
qint64 m_numericData[5];
QString *m_stringData;
char m_characterData[5 * sizeof(qint64) + 3];
};
union {
quint8 m_dataType;
quint8 m_characterDataLength;
};
qint32 m_typeIndex;
void assignData(const QmlEvent &other)
{
switch (m_dataType) {
case StringData:
m_stringData = new QString(*other.m_stringData);
break;
case NumericData:
for (int i = 0; i < 5; ++i)
m_numericData[i] = other.m_numericData[i];
break;
default:
memcpy(m_characterData, other.m_characterData, m_characterDataLength);
break;
}
}
void assignStringData(const QString &data)
{
QByteArray cdata = data.toUtf8();
if (cdata.length() <= (int)sizeof(m_characterData)) {
m_characterDataLength = cdata.length();
memcpy(m_characterData, cdata.constData(), m_characterDataLength);
} else {
m_dataType = StringData;
m_stringData = new QString(data);
}
}
};
} // namespace QmlProfiler

View File

@@ -0,0 +1,50 @@
/****************************************************************************
**
** 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 "qmlprofilereventlocation.h"
#include "qmlprofilereventtypes.h"
#include <QString>
namespace QmlProfiler {
struct QmlEventType {
QmlEventType(const QString &displayName = QString(),
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;
QmlEventLocation location;
Message message;
RangeType rangeType;
int detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType
QString data;
};
} // namespace QmlProfiler

View File

@@ -0,0 +1,43 @@
/****************************************************************************
**
** 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 <QString>
namespace QmlProfiler {
struct QmlNote {
QmlNote(int typeIndex = -1, qint64 startTime = -1, qint64 duration = -1,
const QString &text = QString()) :
typeIndex(typeIndex), startTime(startTime), duration(duration), text(text)
{}
int typeIndex;
qint64 startTime;
qint64 duration;
QString text;
};
} // namespace QmlProfiler

View File

@@ -50,6 +50,9 @@ HEADERS += \
localqmlprofilerrunner.h \ localqmlprofilerrunner.h \
memoryusagemodel.h \ memoryusagemodel.h \
pixmapcachemodel.h \ pixmapcachemodel.h \
qmlevent.h \
qmleventtype.h \
qmlnote.h \
qmlprofiler_global.h \ qmlprofiler_global.h \
qmlprofileranimationsmodel.h \ qmlprofileranimationsmodel.h \
qmlprofilerattachdialog.h \ qmlprofilerattachdialog.h \
@@ -81,7 +84,7 @@ HEADERS += \
qmlprofilertracefile.h \ qmlprofilertracefile.h \
qmlprofilertraceview.h \ qmlprofilertraceview.h \
qmlprofilerviewmanager.h \ qmlprofilerviewmanager.h \
scenegraphtimelinemodel.h \ scenegraphtimelinemodel.h
RESOURCES += \ RESOURCES += \
qml/qmlprofiler.qrc qml/qmlprofiler.qrc

View File

@@ -27,6 +27,7 @@ QtcPlugin {
"localqmlprofilerrunner.cpp", "localqmlprofilerrunner.h", "localqmlprofilerrunner.cpp", "localqmlprofilerrunner.h",
"memoryusagemodel.cpp", "memoryusagemodel.h", "memoryusagemodel.cpp", "memoryusagemodel.h",
"pixmapcachemodel.cpp", "pixmapcachemodel.h", "pixmapcachemodel.cpp", "pixmapcachemodel.h",
"qmlevent.h", "qmleventtype.h", "qmlnote.h",
"qmlprofiler_global.h", "qmlprofiler_global.h",
"qmlprofileranimationsmodel.h", "qmlprofileranimationsmodel.cpp", "qmlprofileranimationsmodel.h", "qmlprofileranimationsmodel.cpp",
"qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h", "qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h",

View File

@@ -54,7 +54,7 @@ void QmlProfilerAnimationsModel::clear()
QmlProfilerTimelineModel::clear(); QmlProfilerTimelineModel::clear();
} }
bool QmlProfilerAnimationsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const bool QmlProfilerAnimationsModel::accepted(const QmlEventType &event) const
{ {
return QmlProfilerTimelineModel::accepted(event) && event.detailType == AnimationFrame; return QmlProfilerTimelineModel::accepted(event) && event.detailType == AnimationFrame;
} }
@@ -66,15 +66,15 @@ void QmlProfilerAnimationsModel::loadData()
return; return;
// collect events // collect events
const QVector<QmlProfilerDataModel::QmlEventData> &referenceList = simpleModel->getEvents(); const QVector<QmlEvent> &referenceList = simpleModel->events();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = simpleModel->getEventTypes(); const QVector<QmlEventType> &typeList = simpleModel->eventTypes();
AnimationThread lastThread; AnimationThread lastThread;
QmlPaintEventData lastEvent; QmlPaintEventData lastEvent;
qint64 minNextStartTimes[] = {0, 0}; qint64 minNextStartTimes[] = {0, 0};
foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) { foreach (const QmlEvent &event, referenceList) {
const QmlProfilerDataModel::QmlEventTypeData &type = typeList[event.typeIndex()]; const QmlEventType &type = typeList[event.typeIndex()];
if (!accepted(type)) if (!accepted(type))
continue; continue;

View File

@@ -64,7 +64,7 @@ public:
QVariantList labels() const; QVariantList labels() const;
QVariantMap details(int index) const; QVariantMap details(int index) const;
bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; bool accepted(const QmlEventType &event) const;
protected: protected:
void loadData(); void loadData();

View File

@@ -39,17 +39,17 @@ namespace QmlProfiler {
class QmlProfilerDataModel::QmlProfilerDataModelPrivate class QmlProfilerDataModel::QmlProfilerDataModelPrivate
{ {
public: public:
QVector<QmlEventTypeData> eventTypes; QVector<QmlEventType> eventTypes;
QVector<QmlEventData> eventList; QVector<QmlEvent> eventList;
QVector<QmlEventNoteData> eventNotes; QVector<QmlNote> eventNotes;
QHash<QmlEventTypeData, int> eventTypeIds; QHash<QmlEventType, int> eventTypeIds;
QmlProfilerModelManager *modelManager; QmlProfilerModelManager *modelManager;
int modelId; int modelId;
Internal::QmlProfilerDetailsRewriter *detailsRewriter; Internal::QmlProfilerDetailsRewriter *detailsRewriter;
}; };
QString getDisplayName(const QmlProfilerDataModel::QmlEventTypeData &event) QString getDisplayName(const QmlEventType &event)
{ {
if (event.location.filename.isEmpty()) { if (event.location.filename.isEmpty()) {
return QmlProfilerDataModel::tr("<bytecode>"); return QmlProfilerDataModel::tr("<bytecode>");
@@ -60,7 +60,7 @@ QString getDisplayName(const QmlProfilerDataModel::QmlEventTypeData &event)
} }
} }
QString getInitialDetails(const QmlProfilerDataModel::QmlEventTypeData &event) QString getInitialDetails(const QmlEventType &event)
{ {
QString details; QString details;
// generate details string // generate details string
@@ -124,27 +124,27 @@ QmlProfilerDataModel::~QmlProfilerDataModel()
delete d; delete d;
} }
const QVector<QmlProfilerDataModel::QmlEventData> &QmlProfilerDataModel::getEvents() const const QVector<QmlEvent> &QmlProfilerDataModel::events() const
{ {
Q_D(const QmlProfilerDataModel); Q_D(const QmlProfilerDataModel);
return d->eventList; return d->eventList;
} }
const QVector<QmlProfilerDataModel::QmlEventTypeData> &QmlProfilerDataModel::getEventTypes() const const QVector<QmlEventType> &QmlProfilerDataModel::eventTypes() const
{ {
Q_D(const QmlProfilerDataModel); Q_D(const QmlProfilerDataModel);
return d->eventTypes; return d->eventTypes;
} }
const QVector<QmlProfilerDataModel::QmlEventNoteData> &QmlProfilerDataModel::getEventNotes() const const QVector<QmlNote> &QmlProfilerDataModel::notes() const
{ {
Q_D(const QmlProfilerDataModel); Q_D(const QmlProfilerDataModel);
return d->eventNotes; return d->eventNotes;
} }
void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd, void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd,
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types, const QVector<QmlEventType> &types,
const QVector<QmlProfilerDataModel::QmlEventData> &events) const QVector<QmlEvent> &events)
{ {
Q_D(QmlProfilerDataModel); Q_D(QmlProfilerDataModel);
d->modelManager->traceTime()->setTime(traceStart, traceEnd); d->modelManager->traceTime()->setTime(traceStart, traceEnd);
@@ -156,7 +156,7 @@ void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd,
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2); d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2);
} }
void QmlProfilerDataModel::setNoteData(const QVector<QmlProfilerDataModel::QmlEventNoteData> &notes) void QmlProfilerDataModel::setNotes(const QVector<QmlNote> &notes)
{ {
Q_D(QmlProfilerDataModel); Q_D(QmlProfilerDataModel);
d->eventNotes = notes; d->eventNotes = notes;
@@ -186,13 +186,12 @@ bool QmlProfilerDataModel::isEmpty() const
return d->eventList.isEmpty(); return d->eventList.isEmpty();
} }
inline static bool operator<(const QmlProfilerDataModel::QmlEventData &t1, inline static bool operator<(const QmlEvent &t1, const QmlEvent &t2)
const QmlProfilerDataModel::QmlEventData &t2)
{ {
return t1.startTime() < t2.startTime(); return t1.startTime() < t2.startTime();
} }
inline static uint qHash(const QmlProfilerDataModel::QmlEventTypeData &type) inline static uint qHash(const QmlEventType &type)
{ {
return qHash(type.location.filename) ^ return qHash(type.location.filename) ^
((type.location.line & 0xfff) | // 12 bits of line number ((type.location.line & 0xfff) | // 12 bits of line number
@@ -202,8 +201,8 @@ inline static uint qHash(const QmlProfilerDataModel::QmlEventTypeData &type)
((type.detailType << 28) & 0xf0000000)); // 4 bits of detailType ((type.detailType << 28) & 0xf0000000)); // 4 bits of detailType
} }
inline static bool operator==(const QmlProfilerDataModel::QmlEventTypeData &type1, inline static bool operator==(const QmlEventType &type1,
const QmlProfilerDataModel::QmlEventTypeData &type2) const QmlEventType &type2)
{ {
return type1.message == type2.message && type1.rangeType == type2.rangeType && return type1.message == type2.message && type1.rangeType == type2.rangeType &&
type1.detailType == type2.detailType && type1.location.line == type2.location.line && type1.detailType == type2.detailType && type1.location.line == type2.location.line &&
@@ -223,7 +222,7 @@ void QmlProfilerDataModel::processData()
// rewrite strings // rewrite strings
int n = d->eventTypes.count(); int n = d->eventTypes.count();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
QmlEventTypeData *event = &d->eventTypes[i]; QmlEventType *event = &d->eventTypes[i];
event->displayName = getDisplayName(*event); event->displayName = getDisplayName(*event);
event->data = getInitialDetails(*event); event->data = getInitialDetails(*event);
@@ -251,21 +250,21 @@ void QmlProfilerDataModel::processData()
emit requestReload(); emit requestReload();
} }
void QmlProfilerDataModel::addQmlEvent(Message message, RangeType rangeType, int detailType, void QmlProfilerDataModel::addEvent(Message message, RangeType rangeType, int detailType,
qint64 startTime, qint64 duration, const QString &data, qint64 startTime, qint64 duration, const QString &data,
const QmlEventLocation &location, qint64 ndata1, const QmlEventLocation &location, qint64 ndata1, qint64 ndata2,
qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5) qint64 ndata3, qint64 ndata4, qint64 ndata5)
{ {
Q_D(QmlProfilerDataModel); Q_D(QmlProfilerDataModel);
QString displayName; QString displayName;
QmlEventTypeData typeData(displayName, location, message, rangeType, detailType, QmlEventType typeData(displayName, location, message, rangeType, detailType,
message == DebugMessage ? QString() : data); message == DebugMessage ? QString() : data);
QmlEventData eventData = (message == DebugMessage) ? QmlEvent eventData = (message == DebugMessage) ?
QmlEventData(startTime, duration, -1, data) : QmlEvent(startTime, duration, -1, data) :
QmlEventData(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5); QmlEvent(startTime, duration, -1, ndata1, ndata2, ndata3, ndata4, ndata5);
QHash<QmlEventTypeData, int>::Iterator it = d->eventTypeIds.find(typeData); QHash<QmlEventType, int>::Iterator it = d->eventTypeIds.find(typeData);
if (it != d->eventTypeIds.end()) { if (it != d->eventTypeIds.end()) {
eventData.setTypeIndex(it.value()); eventData.setTypeIndex(it.value());
} else { } else {
@@ -294,7 +293,7 @@ void QmlProfilerDataModel::detailsChanged(int requestId, const QString &newStrin
Q_D(QmlProfilerDataModel); Q_D(QmlProfilerDataModel);
QTC_ASSERT(requestId < d->eventTypes.count(), return); QTC_ASSERT(requestId < d->eventTypes.count(), return);
QmlEventTypeData *event = &d->eventTypes[requestId]; QmlEventType *event = &d->eventTypes[requestId];
event->data = newString; event->data = newString;
} }

View File

@@ -28,6 +28,9 @@
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilereventtypes.h" #include "qmlprofilereventtypes.h"
#include "qmlprofilereventlocation.h" #include "qmlprofilereventlocation.h"
#include "qmleventtype.h"
#include "qmlevent.h"
#include "qmlnote.h"
#include <utils/fileinprojectfinder.h> #include <utils/fileinprojectfinder.h>
@@ -37,188 +40,26 @@ class QMLPROFILER_EXPORT QmlProfilerDataModel : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
struct QmlEventTypeData {
QmlEventTypeData(const QString &displayName = QString(),
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;
QmlEventLocation location;
Message message;
RangeType rangeType;
int detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType
QString data;
};
struct QmlEventData {
QmlEventData(qint64 startTime = -1, qint64 duration = -1, int typeIndex = -1,
qint64 num0 = 0, qint64 num1 = 0, qint64 num2 = 0, qint64 num3 = 0,
qint64 num4 = 0) :
m_startTime(startTime), m_duration(duration), m_dataType(NumericData),
m_typeIndex(typeIndex)
{
m_numericData[0] = num0;
m_numericData[1] = num1;
m_numericData[2] = num2;
m_numericData[3] = num3;
m_numericData[4] = num4;
}
QmlEventData(qint64 startTime, qint64 duration, int typeIndex, const QString &data)
: m_startTime(startTime), m_duration(duration), m_typeIndex(typeIndex)
{
assignStringData(data);
}
QmlEventData(const QmlEventData &other) :
m_startTime(other.m_startTime), m_duration(other.m_duration),
m_dataType(other.m_dataType), m_typeIndex(other.m_typeIndex)
{
assignData(other);
}
QmlEventData &operator=(const QmlEventData &other)
{
if (this != &other) {
if (m_dataType == StringData)
delete m_stringData;
m_startTime = other.m_startTime;
m_duration = other.m_duration;
m_typeIndex = other.m_typeIndex;
m_dataType = other.m_dataType;
assignData(other);
}
return *this;
}
~QmlEventData()
{
if (m_dataType == StringData)
delete m_stringData;
}
qint64 startTime() const { return m_startTime; }
void setStartTime(qint64 startTime) { m_startTime = startTime; }
qint64 duration() const { return m_duration; }
void setDuration(qint64 duration) { m_duration = duration; }
int typeIndex() const { return m_typeIndex; }
void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; }
qint64 numericData(int i) const { return m_dataType == NumericData ? m_numericData[i] : 0; }
void setNumericData(int i, qint64 data)
{
if (m_dataType == StringData)
delete m_stringData;
m_dataType = NumericData;
m_numericData[i] = data;
}
QString stringData() const
{
switch (m_dataType) {
case NumericData: return QString();
case StringData: return *m_stringData;
default: return QString::fromUtf8(m_characterData, m_characterDataLength);
}
}
void setStringData(const QString &data)
{
if (m_dataType == StringData)
delete m_stringData;
assignStringData(data);
}
private:
static const quint8 StringData = 254;
static const quint8 NumericData = 255;
qint64 m_startTime;
qint64 m_duration;
union {
qint64 m_numericData[5];
QString *m_stringData;
char m_characterData[5 * sizeof(qint64) + 3];
};
union {
quint8 m_dataType;
quint8 m_characterDataLength;
};
qint32 m_typeIndex;
void assignData(const QmlEventData &other)
{
switch (m_dataType) {
case StringData:
m_stringData = new QString(*other.m_stringData);
break;
case NumericData:
for (int i = 0; i < 5; ++i)
m_numericData[i] = other.m_numericData[i];
break;
default:
memcpy(m_characterData, other.m_characterData, m_characterDataLength);
break;
}
}
void assignStringData(const QString &data)
{
QByteArray cdata = data.toUtf8();
if (cdata.length() <= (int)sizeof(m_characterData)) {
m_characterDataLength = cdata.length();
memcpy(m_characterData, cdata.constData(), m_characterDataLength);
} else {
m_dataType = StringData;
m_stringData = new QString(data);
}
}
};
struct QmlEventNoteData {
QmlEventNoteData(int typeIndex = -1, qint64 startTime = -1, qint64 duration = -1,
const QString &text = QString()) :
typeIndex(typeIndex), startTime(startTime), duration(duration), text(text)
{}
int typeIndex;
qint64 startTime;
qint64 duration;
QString text;
};
static QString formatTime(qint64 timestamp); static QString formatTime(qint64 timestamp);
explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder, explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder,
QmlProfilerModelManager *parent); QmlProfilerModelManager *parent);
~QmlProfilerDataModel(); ~QmlProfilerDataModel();
const QVector<QmlEventData> &getEvents() const; const QVector<QmlEvent> &events() const;
const QVector<QmlEventTypeData> &getEventTypes() const; const QVector<QmlEventType> &eventTypes() const;
const QVector<QmlEventNoteData> &getEventNotes() const; const QVector<QmlNote> &notes() const;
void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventTypeData> &types, void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventType> &types,
const QVector<QmlEventData> &events); const QVector<QmlEvent> &events);
void setNoteData(const QVector<QmlEventNoteData> &notes); void setNotes(const QVector<QmlNote> &notes);
void processData(); void processData();
int count() const; int count() const;
void clear(); void clear();
bool isEmpty() const; bool isEmpty() const;
void addQmlEvent(Message message, RangeType rangeType, int bindingType, void addEvent(Message message, RangeType rangeType, int bindingType, qint64 startTime,
qint64 startTime, qint64 duration, const QString &data, qint64 duration, const QString &data, const QmlEventLocation &location,
const QmlEventLocation &location, qint64 ndata1, qint64 ndata2, qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5);
qint64 ndata3, qint64 ndata4, qint64 ndata5);
qint64 lastTimeMark() const; qint64 lastTimeMark() const;
signals: signals:
@@ -235,4 +76,4 @@ private:
Q_DECLARE_PRIVATE(QmlProfilerDataModel) Q_DECLARE_PRIVATE(QmlProfilerDataModel)
}; };
} } // namespace QmlProfiler

View File

@@ -290,16 +290,16 @@ void QmlProfilerModelManager::addQmlEvent(Message message, RangeType rangeType,
d->traceTime->setTime(startTime, startTime + d->traceTime->duration()); d->traceTime->setTime(startTime, startTime + d->traceTime->duration());
QTC_ASSERT(state() == AcquiringData, /**/); QTC_ASSERT(state() == AcquiringData, /**/);
d->model->addQmlEvent(message, rangeType, detailType, startTime, length, data, location, d->model->addEvent(message, rangeType, detailType, startTime, length, data, location, ndata1,
ndata1, ndata2, ndata3, ndata4, ndata5); ndata2, ndata3, ndata4, ndata5);
} }
void QmlProfilerModelManager::addDebugMessage(QtMsgType type, qint64 timestamp, const QString &text, void QmlProfilerModelManager::addDebugMessage(QtMsgType type, qint64 timestamp, const QString &text,
const QmlEventLocation &location) const QmlEventLocation &location)
{ {
if (state() == AcquiringData) if (state() == AcquiringData)
d->model->addQmlEvent(DebugMessage, MaximumRangeType, type, timestamp, 0, text, location, 0, d->model->addEvent(DebugMessage, MaximumRangeType, type, timestamp, 0, text, location, 0, 0,
0, 0, 0, 0); 0, 0, 0);
} }
void QmlProfilerModelManager::acquiringDone() void QmlProfilerModelManager::acquiringDone()
@@ -334,8 +334,8 @@ void QmlProfilerModelManager::save(const QString &filename)
QmlProfilerFileWriter *writer = new QmlProfilerFileWriter(this); QmlProfilerFileWriter *writer = new QmlProfilerFileWriter(this);
writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(), writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
traceTime()->duration()); traceTime()->duration());
writer->setQmlEvents(d->model->getEventTypes(), d->model->getEvents()); writer->setData(d->model->eventTypes(), d->model->events());
writer->setNotes(d->model->getEventNotes()); writer->setNotes(d->model->notes());
connect(writer, &QObject::destroyed, this, &QmlProfilerModelManager::saveFinished, connect(writer, &QObject::destroyed, this, &QmlProfilerModelManager::saveFinished,
Qt::QueuedConnection); Qt::QueuedConnection);
@@ -372,8 +372,8 @@ void QmlProfilerModelManager::load(const QString &filename)
connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() { connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() {
d->model->setData(reader->traceStart(), qMax(reader->traceStart(), reader->traceEnd()), d->model->setData(reader->traceStart(), qMax(reader->traceStart(), reader->traceEnd()),
reader->qmlEvents(), reader->ranges()); reader->eventTypes(), reader->events());
d->model->setNoteData(reader->notes()); d->model->setNotes(reader->notes());
setRecordedFeatures(reader->loadedFeatures()); setRecordedFeatures(reader->loadedFeatures());
d->traceTime->increaseEndTime(d->model->lastTimeMark()); d->traceTime->increaseEndTime(d->model->lastTimeMark());
delete reader; delete reader;

View File

@@ -70,10 +70,9 @@ void QmlProfilerNotesModel::loadData()
{ {
blockSignals(true); blockSignals(true);
clear(); clear();
const QVector<QmlProfilerDataModel::QmlEventNoteData> &notes = const QVector<QmlNote> &notes = m_modelManager->qmlModel()->notes();
m_modelManager->qmlModel()->getEventNotes();
for (int i = 0; i != notes.size(); ++i) { for (int i = 0; i != notes.size(); ++i) {
const QmlProfilerDataModel::QmlEventNoteData &note = notes[i]; const QmlNote &note = notes[i];
add(note.typeIndex, note.startTime, note.duration, note.text); add(note.typeIndex, note.startTime, note.duration, note.text);
} }
resetModified(); resetModified();
@@ -83,14 +82,14 @@ void QmlProfilerNotesModel::loadData()
void QmlProfilerNotesModel::saveData() void QmlProfilerNotesModel::saveData()
{ {
QVector<QmlProfilerDataModel::QmlEventNoteData> notes; QVector<QmlNote> notes;
for (int i = 0; i < count(); ++i) { for (int i = 0; i < count(); ++i) {
const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i)); const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i));
if (!model) if (!model)
continue; continue;
int index = timelineIndex(i); int index = timelineIndex(i);
QmlProfilerDataModel::QmlEventNoteData save = { QmlNote save = {
model->typeId(index), model->typeId(index),
model->startTime(index), model->startTime(index),
model->duration(index), model->duration(index),
@@ -98,7 +97,7 @@ void QmlProfilerNotesModel::saveData()
}; };
notes.append(save); notes.append(save);
} }
m_modelManager->qmlModel()->setNoteData(notes); m_modelManager->qmlModel()->setNotes(notes);
resetModified(); resetModified();
} }
} }

View File

@@ -71,10 +71,10 @@ void QmlProfilerRangeModel::loadData()
return; return;
// collect events // collect events
const QVector<QmlProfilerDataModel::QmlEventData> &eventList = simpleModel->getEvents(); const QVector<QmlEvent> &eventList = simpleModel->events();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typesList = simpleModel->getEventTypes(); const QVector<QmlEventType> &typesList = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { foreach (const QmlEvent &event, eventList) {
const QmlProfilerDataModel::QmlEventTypeData &type = typesList[event.typeIndex()]; const QmlEventType &type = typesList[event.typeIndex()];
if (!accepted(type)) if (!accepted(type))
continue; continue;
@@ -204,8 +204,7 @@ QVariantList QmlProfilerRangeModel::labels() const
{ {
QVariantList result; QVariantList result;
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = const QVector<QmlEventType> &types = modelManager()->qmlModel()->eventTypes();
modelManager()->qmlModel()->getEventTypes();
for (int i = 1; i < expandedRowCount(); i++) { // Ignore the -1 for the first row for (int i = 1; i < expandedRowCount(); i++) { // Ignore the -1 for the first row
QVariantMap element; QVariantMap element;
int typeId = m_expandedRowTypes[i]; int typeId = m_expandedRowTypes[i];
@@ -222,8 +221,7 @@ QVariantMap QmlProfilerRangeModel::details(int index) const
{ {
QVariantMap result; QVariantMap result;
int id = selectionId(index); int id = selectionId(index);
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = const QVector<QmlEventType> &types = modelManager()->qmlModel()->eventTypes();
modelManager()->qmlModel()->getEventTypes();
result.insert(QStringLiteral("displayName"), result.insert(QStringLiteral("displayName"),
tr(QmlProfilerModelManager::featureName(mainFeature()))); tr(QmlProfilerModelManager::featureName(mainFeature())));
@@ -247,11 +245,10 @@ int QmlProfilerRangeModel::typeId(int index) const
int QmlProfilerRangeModel::selectionIdForLocation(const QString &filename, int line, int column) const int QmlProfilerRangeModel::selectionIdForLocation(const QString &filename, int line, int column) const
{ {
// if this is called from v8 view, we don't have the column number, it will be -1 // if this is called from v8 view, we don't have the column number, it will be -1
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = const QVector<QmlEventType> &types = modelManager()->qmlModel()->eventTypes();
modelManager()->qmlModel()->getEventTypes();
for (int i = 1; i < expandedRowCount(); ++i) { for (int i = 1; i < expandedRowCount(); ++i) {
int typeId = m_expandedRowTypes[i]; int typeId = m_expandedRowTypes[i];
const QmlProfilerDataModel::QmlEventTypeData &eventData = types[typeId]; const QmlEventType &eventData = types[typeId];
if (eventData.location.filename == filename && if (eventData.location.filename == filename &&
eventData.location.line == line && eventData.location.line == line &&
(column == -1 || eventData.location.column == column)) (column == -1 || eventData.location.column == column))

View File

@@ -97,9 +97,9 @@ const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &QmlProfilerStatisti
return d->data; return d->data;
} }
const QVector<QmlProfilerDataModel::QmlEventTypeData> &QmlProfilerStatisticsModel::getTypes() const const QVector<QmlEventType> &QmlProfilerStatisticsModel::getTypes() const
{ {
return d->modelManager->qmlModel()->getEventTypes(); return d->modelManager->qmlModel()->eventTypes();
} }
const QHash<int, QString> &QmlProfilerStatisticsModel::getNotes() const const QHash<int, QString> &QmlProfilerStatisticsModel::getNotes() const
@@ -176,18 +176,16 @@ void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd)
const bool checkRanges = (rangeStart != -1) && (rangeEnd != -1); const bool checkRanges = (rangeStart != -1) && (rangeEnd != -1);
const QVector<QmlProfilerDataModel::QmlEventData> &eventList const QVector<QmlEvent> &eventList = d->modelManager->qmlModel()->events();
= d->modelManager->qmlModel()->getEvents(); const QVector<QmlEventType> &typesList = d->modelManager->qmlModel()->eventTypes();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typesList
= d->modelManager->qmlModel()->getEventTypes();
// used by binding loop detection // used by binding loop detection
QStack<const QmlProfilerDataModel::QmlEventData*> callStack; QStack<const QmlEvent*> callStack;
callStack.push(0); // artificial root callStack.push(0); // artificial root
for (int i = 0; i < eventList.size(); ++i) { for (int i = 0; i < eventList.size(); ++i) {
const QmlProfilerDataModel::QmlEventData *event = &eventList[i]; const QmlEvent *event = &eventList[i];
const QmlProfilerDataModel::QmlEventTypeData *type = &typesList[event->typeIndex()]; const QmlEventType *type = &typesList[event->typeIndex()];
if (!d->acceptedTypes.contains(type->rangeType)) if (!d->acceptedTypes.contains(type->rangeType))
continue; continue;
@@ -221,7 +219,7 @@ void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd)
// //
// binding loop detection // binding loop detection
// //
const QmlProfilerDataModel::QmlEventData *potentialParent = callStack.top(); const QmlEvent *potentialParent = callStack.top();
while (potentialParent && !(potentialParent->startTime() + potentialParent->duration() > while (potentialParent && !(potentialParent->startTime() + potentialParent->duration() >
event->startTime())) { event->startTime())) {
callStack.pop(); callStack.pop();
@@ -315,10 +313,9 @@ QmlProfilerStatisticsRelativesModel::getData(int typeId) const
} }
} }
const QVector<QmlProfilerDataModel::QmlEventTypeData> & const QVector<QmlEventType> &QmlProfilerStatisticsRelativesModel::getTypes() const
QmlProfilerStatisticsRelativesModel::getTypes() const
{ {
return m_modelManager->qmlModel()->getEventTypes(); return m_modelManager->qmlModel()->eventTypes();
} }
int QmlProfilerStatisticsRelativesModel::count() const int QmlProfilerStatisticsRelativesModel::count() const
@@ -360,9 +357,9 @@ void QmlProfilerStatisticsParentsModel::loadData()
// compute parent-child relationship and call count // compute parent-child relationship and call count
QHash<int, int> lastParent; QHash<int, int> lastParent;
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents(); const QVector<QmlEvent> eventList = simpleModel->events();
const QVector<QmlProfilerDataModel::QmlEventTypeData> typesList = simpleModel->getEventTypes(); const QVector<QmlEventType> typesList = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { foreach (const QmlEvent &event, eventList) {
// whitelist // whitelist
if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType)) if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType))
continue; continue;
@@ -422,9 +419,9 @@ void QmlProfilerStatisticsChildrenModel::loadData()
// compute parent-child relationship and call count // compute parent-child relationship and call count
QHash<int, int> lastParent; QHash<int, int> lastParent;
const QVector<QmlProfilerDataModel::QmlEventData> &eventList = simpleModel->getEvents(); const QVector<QmlEvent> &eventList = simpleModel->events();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typesList = simpleModel->getEventTypes(); const QVector<QmlEventType> &typesList = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { foreach (const QmlEvent &event, eventList) {
// whitelist // whitelist
if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType)) if (!m_statisticsModel->eventTypeAccepted(typesList[event.typeIndex()].rangeType))
continue; continue;

View File

@@ -65,7 +65,7 @@ public:
bool eventTypeAccepted(RangeType) const; bool eventTypeAccepted(RangeType) const;
const QHash<int, QmlEventStats> &getData() const; const QHash<int, QmlEventStats> &getData() const;
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const; const QVector<QmlEventType> &getTypes() const;
const QHash<int, QString> &getNotes() const; const QHash<int, QString> &getNotes() const;
int count() const; int count() const;
@@ -112,7 +112,7 @@ public:
void clear(); void clear();
const QmlStatisticsRelativesMap &getData(int typeId) const; const QmlStatisticsRelativesMap &getData(int typeId) const;
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const; const QVector<QmlEventType> &getTypes() const;
protected: protected:
virtual void loadData() = 0; virtual void loadData() = 0;

View File

@@ -57,7 +57,7 @@ struct Colors {
QColor defaultBackground; QColor defaultBackground;
}; };
struct RootEventType : public QmlProfilerDataModel::QmlEventTypeData { struct RootEventType : public QmlEventType {
RootEventType() RootEventType()
{ {
QString rootEventName = QmlProfilerStatisticsMainView::tr("<program>"); QString rootEventName = QmlProfilerStatisticsMainView::tr("<program>");
@@ -555,8 +555,7 @@ void QmlProfilerStatisticsMainView::buildModel()
void QmlProfilerStatisticsMainView::updateNotes(int typeIndex) void QmlProfilerStatisticsMainView::updateNotes(int typeIndex)
{ {
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = d->model->getData();
d->model->getData();
const QHash<int, QString> &noteList = d->model->getNotes(); const QHash<int, QString> &noteList = d->model->getNotes();
QStandardItem *parentItem = d->m_model->invisibleRootItem(); QStandardItem *parentItem = d->m_model->invisibleRootItem();
@@ -585,17 +584,15 @@ void QmlProfilerStatisticsMainView::updateNotes(int typeIndex)
void QmlProfilerStatisticsMainView::parseModel() void QmlProfilerStatisticsMainView::parseModel()
{ {
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = d->model->getData();
d->model->getData(); const QVector<QmlEventType> &typeList = d->model->getTypes();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->model->getTypes();
QHash<int, QmlProfilerStatisticsModel::QmlEventStats>::ConstIterator it; QHash<int, QmlProfilerStatisticsModel::QmlEventStats>::ConstIterator it;
for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) { for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) {
int typeIndex = it.key(); int typeIndex = it.key();
const QmlProfilerStatisticsModel::QmlEventStats &stats = it.value(); const QmlProfilerStatisticsModel::QmlEventStats &stats = it.value();
const QmlProfilerDataModel::QmlEventTypeData &event = const QmlEventType &event = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
(typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
QStandardItem *parentItem = d->m_model->invisibleRootItem(); QStandardItem *parentItem = d->m_model->invisibleRootItem();
QList<QStandardItem *> newRow; QList<QStandardItem *> newRow;
@@ -889,14 +886,13 @@ void QmlProfilerStatisticsRelativesView::rebuildTree(
treeModel()->clear(); treeModel()->clear();
QStandardItem *topLevelItem = treeModel()->invisibleRootItem(); QStandardItem *topLevelItem = treeModel()->invisibleRootItem();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->model->getTypes(); const QVector<QmlEventType> &typeList = d->model->getTypes();
QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap::const_iterator it; QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap::const_iterator it;
for (it = map.constBegin(); it != map.constEnd(); ++it) { for (it = map.constBegin(); it != map.constEnd(); ++it) {
const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesData &event = it.value(); const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesData &event = it.value();
int typeIndex = it.key(); int typeIndex = it.key();
const QmlProfilerDataModel::QmlEventTypeData &type = const QmlEventType &type = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
(typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
QList<QStandardItem *> newRow; QList<QStandardItem *> newRow;
// ToDo: here we were going to search for the data in the other model // ToDo: here we were going to search for the data in the other model

View File

@@ -57,7 +57,7 @@ ProfileFeature QmlProfilerTimelineModel::mainFeature() const
return m_mainFeature; return m_mainFeature;
} }
bool QmlProfilerTimelineModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const bool QmlProfilerTimelineModel::accepted(const QmlEventType &event) const
{ {
return (event.rangeType == m_rangeType && event.message == m_message); return (event.rangeType == m_rangeType && event.message == m_message);
} }
@@ -67,7 +67,7 @@ bool QmlProfilerTimelineModel::handlesTypeId(int typeIndex) const
if (typeIndex < 0) if (typeIndex < 0)
return false; return false;
return accepted(modelManager()->qmlModel()->getEventTypes().at(typeIndex)); return accepted(modelManager()->qmlModel()->eventTypes().at(typeIndex));
} }
void QmlProfilerTimelineModel::clear() void QmlProfilerTimelineModel::clear()
@@ -127,7 +127,7 @@ QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const
if (id < 0) if (id < 0)
return result; return result;
auto types = modelManager()->qmlModel()->getEventTypes(); auto types = modelManager()->qmlModel()->eventTypes();
if (id >= types.length()) if (id >= types.length())
return result; return result;

View File

@@ -48,7 +48,7 @@ public:
Message message() const; Message message() const;
ProfileFeature mainFeature() const; ProfileFeature mainFeature() const;
virtual bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; virtual bool accepted(const QmlEventType &event) const;
bool handlesTypeId(int typeId) const; bool handlesTypeId(int typeId) const;
Q_INVOKABLE virtual int bindingLoopDest(int index) const; Q_INVOKABLE virtual int bindingLoopDest(int index) const;
QVariantMap locationFromTypeId(int index) const; QVariantMap locationFromTypeId(int index) const;

View File

@@ -158,17 +158,17 @@ bool QmlProfilerFileReader::load(QIODevice *device)
} }
if (elementName == _("eventData")) { if (elementName == _("eventData")) {
loadEventData(stream); loadEventTypes(stream);
break; break;
} }
if (elementName == _("profilerDataModel")) { if (elementName == _("profilerDataModel")) {
loadProfilerDataModel(stream); loadEvents(stream);
break; break;
} }
if (elementName == _("noteData")) { if (elementName == _("noteData")) {
loadNoteData(stream); loadNotes(stream);
break; break;
} }
@@ -192,13 +192,13 @@ quint64 QmlProfilerFileReader::loadedFeatures() const
return m_loadedFeatures; return m_loadedFeatures;
} }
ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTypeData &event) { ProfileFeature featureFromType(const QmlEventType &type) {
if (event.rangeType < MaximumRangeType) if (type.rangeType < MaximumRangeType)
return featureFromRangeType(event.rangeType); return featureFromRangeType(type.rangeType);
switch (event.message) { switch (type.message) {
case Event: case Event:
switch (event.detailType) { switch (type.detailType) {
case AnimationFrame: case AnimationFrame:
return ProfileAnimations; return ProfileAnimations;
case Key: case Key:
@@ -220,12 +220,12 @@ ProfileFeature featureFromEvent(const QmlProfilerDataModel::QmlEventTypeData &ev
} }
} }
void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) void QmlProfilerFileReader::loadEventTypes(QXmlStreamReader &stream)
{ {
QTC_ASSERT(stream.name() == _("eventData"), return); QTC_ASSERT(stream.name() == _("eventData"), return);
int eventIndex = -1; int typeIndex = -1;
QmlProfilerDataModel::QmlEventTypeData event = { QmlEventType type = {
QString(), // displayname QString(), // displayname
QmlEventLocation(), QmlEventLocation(),
MaximumMessage, MaximumMessage,
@@ -233,7 +233,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
QmlBinding, // bindingType, set for backwards compatibility QmlBinding, // bindingType, set for backwards compatibility
QString(), // details QString(), // details
}; };
const QmlProfilerDataModel::QmlEventTypeData defaultEvent = event; const QmlEventType defaultEvent = type;
while (!stream.atEnd() && !stream.hasError()) { while (!stream.atEnd() && !stream.hasError()) {
if (isCanceled()) if (isCanceled())
@@ -246,14 +246,14 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
case QXmlStreamReader::StartElement: { case QXmlStreamReader::StartElement: {
if (elementName == _("event")) { if (elementName == _("event")) {
progress(stream.device()); progress(stream.device());
event = defaultEvent; type = defaultEvent;
const QXmlStreamAttributes attributes = stream.attributes(); const QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute(_("index"))) { if (attributes.hasAttribute(_("index"))) {
eventIndex = attributes.value(_("index")).toInt(); typeIndex = attributes.value(_("index")).toInt();
} else { } else {
// ignore event // ignore event
eventIndex = -1; typeIndex = -1;
} }
break; break;
} }
@@ -265,47 +265,47 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
const QString readData = stream.text().toString(); const QString readData = stream.text().toString();
if (elementName == _("displayname")) { if (elementName == _("displayname")) {
event.displayName = readData; type.displayName = readData;
break; break;
} }
if (elementName == _("type")) { if (elementName == _("type")) {
QPair<Message, RangeType> enums = qmlTypeAsEnum(readData); QPair<Message, RangeType> enums = qmlTypeAsEnum(readData);
event.message = enums.first; type.message = enums.first;
event.rangeType = enums.second; type.rangeType = enums.second;
break; break;
} }
if (elementName == _("filename")) { if (elementName == _("filename")) {
event.location.filename = readData; type.location.filename = readData;
break; break;
} }
if (elementName == _("line")) { if (elementName == _("line")) {
event.location.line = readData.toInt(); type.location.line = readData.toInt();
break; break;
} }
if (elementName == _("column")) { if (elementName == _("column")) {
event.location.column = readData.toInt(); type.location.column = readData.toInt();
break; break;
} }
if (elementName == _("details")) { if (elementName == _("details")) {
event.data = readData; type.data = readData;
break; break;
} }
if (elementName == _("animationFrame")) { if (elementName == _("animationFrame")) {
event.detailType = readData.toInt(); type.detailType = readData.toInt();
// new animation frames used to be saved as ranges of range type Painting with // new animation frames used to be saved as ranges of range type Painting with
// binding type 4 (which was called "AnimationFrame" to make everything even more // binding type 4 (which was called "AnimationFrame" to make everything even more
// confusing), even though they clearly aren't ranges. Convert that to something // confusing), even though they clearly aren't ranges. Convert that to something
// sane here. // sane here.
if (event.detailType == 4) { if (type.detailType == 4) {
event.message = Event; type.message = Event;
event.rangeType = MaximumRangeType; type.rangeType = MaximumRangeType;
event.detailType = AnimationFrame; type.detailType = AnimationFrame;
} }
} }
@@ -316,7 +316,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
elementName == _("mouseEvent") || elementName == _("mouseEvent") ||
elementName == _("keyEvent") || elementName == _("keyEvent") ||
elementName == _("level")) { elementName == _("level")) {
event.detailType = readData.toInt(); type.detailType = readData.toInt();
break; break;
} }
@@ -324,11 +324,11 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
} }
case QXmlStreamReader::EndElement: { case QXmlStreamReader::EndElement: {
if (elementName == _("event")) { if (elementName == _("event")) {
if (eventIndex >= 0) { if (typeIndex >= 0) {
if (eventIndex >= m_qmlEvents.size()) if (typeIndex >= m_eventTypes.size())
m_qmlEvents.resize(eventIndex + 1); m_eventTypes.resize(typeIndex + 1);
m_qmlEvents[eventIndex] = event; m_eventTypes[typeIndex] = type;
ProfileFeature feature = featureFromEvent(event); ProfileFeature feature = featureFromType(type);
if (feature != MaximumProfileFeature) if (feature != MaximumProfileFeature)
m_loadedFeatures |= (1ULL << static_cast<uint>(feature)); m_loadedFeatures |= (1ULL << static_cast<uint>(feature));
} }
@@ -346,7 +346,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
} }
} }
void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream) void QmlProfilerFileReader::loadEvents(QXmlStreamReader &stream)
{ {
QTC_ASSERT(stream.name() == _("profilerDataModel"), return); QTC_ASSERT(stream.name() == _("profilerDataModel"), return);
@@ -361,7 +361,7 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream)
case QXmlStreamReader::StartElement: { case QXmlStreamReader::StartElement: {
if (elementName == _("range")) { if (elementName == _("range")) {
progress(stream.device()); progress(stream.device());
QmlProfilerDataModel::QmlEventData range(0, 0, -1, 0, 0, 0, 0, 0); QmlEvent event(0, 0, -1, 0, 0, 0, 0, 0);
const QXmlStreamAttributes attributes = stream.attributes(); const QXmlStreamAttributes attributes = stream.attributes();
if (!attributes.hasAttribute(_("startTime")) if (!attributes.hasAttribute(_("startTime"))
@@ -370,47 +370,47 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream)
continue; continue;
} }
range.setStartTime(attributes.value(_("startTime")).toLongLong()); event.setStartTime(attributes.value(_("startTime")).toLongLong());
if (attributes.hasAttribute(_("duration"))) if (attributes.hasAttribute(_("duration")))
range.setDuration(attributes.value(_("duration")).toLongLong()); event.setDuration(attributes.value(_("duration")).toLongLong());
// attributes for special events // attributes for special events
if (attributes.hasAttribute(_("framerate"))) if (attributes.hasAttribute(_("framerate")))
range.setNumericData(0, attributes.value(_("framerate")).toLongLong()); event.setNumericData(0, attributes.value(_("framerate")).toLongLong());
if (attributes.hasAttribute(_("animationcount"))) if (attributes.hasAttribute(_("animationcount")))
range.setNumericData(1, attributes.value(_("animationcount")).toLongLong()); event.setNumericData(1, attributes.value(_("animationcount")).toLongLong());
if (attributes.hasAttribute(_("thread"))) if (attributes.hasAttribute(_("thread")))
range.setNumericData(2, attributes.value(_("thread")).toLongLong()); event.setNumericData(2, attributes.value(_("thread")).toLongLong());
if (attributes.hasAttribute(_("width"))) if (attributes.hasAttribute(_("width")))
range.setNumericData(0, attributes.value(_("width")).toLongLong()); event.setNumericData(0, attributes.value(_("width")).toLongLong());
if (attributes.hasAttribute(_("height"))) if (attributes.hasAttribute(_("height")))
range.setNumericData(1, attributes.value(_("height")).toLongLong()); event.setNumericData(1, attributes.value(_("height")).toLongLong());
if (attributes.hasAttribute(_("refCount"))) if (attributes.hasAttribute(_("refCount")))
range.setNumericData(2, attributes.value(_("refCount")).toLongLong()); event.setNumericData(2, attributes.value(_("refCount")).toLongLong());
if (attributes.hasAttribute(_("amount"))) if (attributes.hasAttribute(_("amount")))
range.setNumericData(0, attributes.value(_("amount")).toLongLong()); event.setNumericData(0, attributes.value(_("amount")).toLongLong());
if (attributes.hasAttribute(_("timing1"))) if (attributes.hasAttribute(_("timing1")))
range.setNumericData(0, attributes.value(_("timing1")).toLongLong()); event.setNumericData(0, attributes.value(_("timing1")).toLongLong());
if (attributes.hasAttribute(_("timing2"))) if (attributes.hasAttribute(_("timing2")))
range.setNumericData(1, attributes.value(_("timing2")).toLongLong()); event.setNumericData(1, attributes.value(_("timing2")).toLongLong());
if (attributes.hasAttribute(_("timing3"))) if (attributes.hasAttribute(_("timing3")))
range.setNumericData(2, attributes.value(_("timing3")).toLongLong()); event.setNumericData(2, attributes.value(_("timing3")).toLongLong());
if (attributes.hasAttribute(_("timing4"))) if (attributes.hasAttribute(_("timing4")))
range.setNumericData(3, attributes.value(_("timing4")).toLongLong()); event.setNumericData(3, attributes.value(_("timing4")).toLongLong());
if (attributes.hasAttribute(_("timing5"))) if (attributes.hasAttribute(_("timing5")))
range.setNumericData(4, attributes.value(_("timing5")).toLongLong()); event.setNumericData(4, attributes.value(_("timing5")).toLongLong());
if (attributes.hasAttribute(_("type"))) if (attributes.hasAttribute(_("type")))
range.setNumericData(0, attributes.value(_("type")).toLongLong()); event.setNumericData(0, attributes.value(_("type")).toLongLong());
if (attributes.hasAttribute(_("data1"))) if (attributes.hasAttribute(_("data1")))
range.setNumericData(1, attributes.value(_("data1")).toLongLong()); event.setNumericData(1, attributes.value(_("data1")).toLongLong());
if (attributes.hasAttribute(_("data2"))) if (attributes.hasAttribute(_("data2")))
range.setNumericData(2, attributes.value(_("data2")).toLongLong()); event.setNumericData(2, attributes.value(_("data2")).toLongLong());
if (attributes.hasAttribute(_("text"))) if (attributes.hasAttribute(_("text")))
range.setStringData(attributes.value(_("text")).toString()); event.setStringData(attributes.value(_("text")).toString());
range.setTypeIndex(attributes.value(_("eventIndex")).toInt()); event.setTypeIndex(attributes.value(_("eventIndex")).toInt());
m_ranges.append(range); m_events.append(event);
} }
break; break;
} }
@@ -426,9 +426,9 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream)
} }
} }
void QmlProfilerFileReader::loadNoteData(QXmlStreamReader &stream) void QmlProfilerFileReader::loadNotes(QXmlStreamReader &stream)
{ {
QmlProfilerDataModel::QmlEventNoteData currentNote; QmlNote currentNote;
while (!stream.atEnd() && !stream.hasError()) { while (!stream.atEnd() && !stream.hasError()) {
if (isCanceled()) if (isCanceled())
return; return;
@@ -494,14 +494,14 @@ void QmlProfilerFileWriter::setTraceTime(qint64 startTime, qint64 endTime, qint6
m_measuredTime = measuredTime; m_measuredTime = measuredTime;
} }
void QmlProfilerFileWriter::setQmlEvents(const QVector<QmlProfilerDataModel::QmlEventTypeData> &types, void QmlProfilerFileWriter::setData(const QVector<QmlEventType> &types,
const QVector<QmlProfilerDataModel::QmlEventData> &events) const QVector<QmlEvent> &events)
{ {
m_qmlEvents = types; m_eventTypes = types;
m_ranges = events; m_events = events;
} }
void QmlProfilerFileWriter::setNotes(const QVector<QmlProfilerDataModel::QmlEventNoteData> &notes) void QmlProfilerFileWriter::setNotes(const QVector<QmlNote> &notes)
{ {
m_notes = notes; m_notes = notes;
} }
@@ -515,7 +515,7 @@ void QmlProfilerFileWriter::save(QIODevice *device)
{ {
if (m_future) { if (m_future) {
m_future->setProgressRange(0, m_future->setProgressRange(0,
qMax(m_qmlEvents.size() + m_ranges.size() + m_notes.size(), 1)); qMax(m_eventTypes.size() + m_events.size() + m_notes.size(), 1));
m_future->setProgressValue(0); m_future->setProgressValue(0);
m_newProgressValue = 0; m_newProgressValue = 0;
} }
@@ -534,49 +534,49 @@ void QmlProfilerFileWriter::save(QIODevice *device)
stream.writeStartElement(_("eventData")); stream.writeStartElement(_("eventData"));
stream.writeAttribute(_("totalTime"), QString::number(m_measuredTime)); stream.writeAttribute(_("totalTime"), QString::number(m_measuredTime));
for (int typeIndex = 0; typeIndex < m_qmlEvents.size(); ++typeIndex) { for (int typeIndex = 0; typeIndex < m_eventTypes.size(); ++typeIndex) {
if (isCanceled()) if (isCanceled())
return; return;
const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[typeIndex]; const QmlEventType &type = m_eventTypes[typeIndex];
stream.writeStartElement(_("event")); stream.writeStartElement(_("event"));
stream.writeAttribute(_("index"), QString::number(typeIndex)); stream.writeAttribute(_("index"), QString::number(typeIndex));
stream.writeTextElement(_("displayname"), event.displayName); stream.writeTextElement(_("displayname"), type.displayName);
stream.writeTextElement(_("type"), qmlTypeAsString(event.message, event.rangeType)); stream.writeTextElement(_("type"), qmlTypeAsString(type.message, type.rangeType));
if (!event.location.filename.isEmpty()) { if (!type.location.filename.isEmpty()) {
stream.writeTextElement(_("filename"), event.location.filename); stream.writeTextElement(_("filename"), type.location.filename);
stream.writeTextElement(_("line"), QString::number(event.location.line)); stream.writeTextElement(_("line"), QString::number(type.location.line));
stream.writeTextElement(_("column"), QString::number(event.location.column)); stream.writeTextElement(_("column"), QString::number(type.location.column));
} }
if (!event.data.isEmpty()) if (!type.data.isEmpty())
stream.writeTextElement(_("details"), event.data); stream.writeTextElement(_("details"), type.data);
if (event.rangeType == Binding) { if (type.rangeType == Binding) {
stream.writeTextElement(_("bindingType"), QString::number(event.detailType)); stream.writeTextElement(_("bindingType"), QString::number(type.detailType));
} else if (event.message == Event) { } else if (type.message == Event) {
switch (event.detailType) { switch (type.detailType) {
case AnimationFrame: case AnimationFrame:
stream.writeTextElement(_("animationFrame"), QString::number(event.detailType)); stream.writeTextElement(_("animationFrame"), QString::number(type.detailType));
break; break;
case Key: case Key:
stream.writeTextElement(_("keyEvent"), QString::number(event.detailType)); stream.writeTextElement(_("keyEvent"), QString::number(type.detailType));
break; break;
case Mouse: case Mouse:
stream.writeTextElement(_("mouseEvent"), QString::number(event.detailType)); stream.writeTextElement(_("mouseEvent"), QString::number(type.detailType));
break; break;
default: default:
break; break;
} }
} else if (event.message == PixmapCacheEvent) { } else if (type.message == PixmapCacheEvent) {
stream.writeTextElement(_("cacheEventType"), QString::number(event.detailType)); stream.writeTextElement(_("cacheEventType"), QString::number(type.detailType));
} else if (event.message == SceneGraphFrame) { } else if (type.message == SceneGraphFrame) {
stream.writeTextElement(_("sgEventType"), QString::number(event.detailType)); stream.writeTextElement(_("sgEventType"), QString::number(type.detailType));
} else if (event.message == MemoryAllocation) { } else if (type.message == MemoryAllocation) {
stream.writeTextElement(_("memoryEventType"), QString::number(event.detailType)); stream.writeTextElement(_("memoryEventType"), QString::number(type.detailType));
} else if (event.message == DebugMessage) { } else if (type.message == DebugMessage) {
stream.writeTextElement(_("level"), QString::number(event.detailType)); stream.writeTextElement(_("level"), QString::number(type.detailType));
} }
stream.writeEndElement(); stream.writeEndElement();
incrementProgress(); incrementProgress();
@@ -585,67 +585,67 @@ void QmlProfilerFileWriter::save(QIODevice *device)
stream.writeStartElement(_("profilerDataModel")); stream.writeStartElement(_("profilerDataModel"));
for (int rangeIndex = 0; rangeIndex < m_ranges.size(); ++rangeIndex) { for (int rangeIndex = 0; rangeIndex < m_events.size(); ++rangeIndex) {
if (isCanceled()) if (isCanceled())
return; return;
const QmlProfilerDataModel::QmlEventData &range = m_ranges[rangeIndex]; const QmlEvent &event = m_events[rangeIndex];
stream.writeStartElement(_("range")); stream.writeStartElement(_("range"));
stream.writeAttribute(_("startTime"), QString::number(range.startTime())); stream.writeAttribute(_("startTime"), QString::number(event.startTime()));
if (range.duration() > 0) // no need to store duration of instantaneous events if (event.duration() > 0) // no need to store duration of instantaneous events
stream.writeAttribute(_("duration"), QString::number(range.duration())); stream.writeAttribute(_("duration"), QString::number(event.duration()));
stream.writeAttribute(_("eventIndex"), QString::number(range.typeIndex())); stream.writeAttribute(_("eventIndex"), QString::number(event.typeIndex()));
const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[range.typeIndex()]; const QmlEventType &type = m_eventTypes[event.typeIndex()];
if (event.message == Event) { if (type.message == Event) {
if (event.detailType == AnimationFrame) { if (type.detailType == AnimationFrame) {
// special: animation event // special: animation event
stream.writeAttribute(_("framerate"), QString::number(range.numericData(0))); stream.writeAttribute(_("framerate"), QString::number(event.numericData(0)));
stream.writeAttribute(_("animationcount"), QString::number(range.numericData(1))); stream.writeAttribute(_("animationcount"), QString::number(event.numericData(1)));
stream.writeAttribute(_("thread"), QString::number(range.numericData(2))); stream.writeAttribute(_("thread"), QString::number(event.numericData(2)));
} else if (event.detailType == Key || event.detailType == Mouse) { } else if (type.detailType == Key || type.detailType == Mouse) {
// special: input event // special: input event
stream.writeAttribute(_("type"), QString::number(range.numericData(0))); stream.writeAttribute(_("type"), QString::number(event.numericData(0)));
stream.writeAttribute(_("data1"), QString::number(range.numericData(1))); stream.writeAttribute(_("data1"), QString::number(event.numericData(1)));
stream.writeAttribute(_("data2"), QString::number(range.numericData(2))); stream.writeAttribute(_("data2"), QString::number(event.numericData(2)));
} }
} }
// special: pixmap cache event // special: pixmap cache event
if (event.message == PixmapCacheEvent) { if (type.message == PixmapCacheEvent) {
if (event.detailType == PixmapSizeKnown) { if (type.detailType == PixmapSizeKnown) {
stream.writeAttribute(_("width"), QString::number(range.numericData(0))); stream.writeAttribute(_("width"), QString::number(event.numericData(0)));
stream.writeAttribute(_("height"), QString::number(range.numericData(1))); stream.writeAttribute(_("height"), QString::number(event.numericData(1)));
} }
if (event.detailType == PixmapReferenceCountChanged || if (type.detailType == PixmapReferenceCountChanged ||
event.detailType == PixmapCacheCountChanged) type.detailType == PixmapCacheCountChanged)
stream.writeAttribute(_("refCount"), QString::number(range.numericData(2))); stream.writeAttribute(_("refCount"), QString::number(event.numericData(2)));
} }
if (event.message == SceneGraphFrame) { if (type.message == SceneGraphFrame) {
// special: scenegraph frame events // special: scenegraph frame events
if (range.numericData(0) > 0) if (event.numericData(0) > 0)
stream.writeAttribute(_("timing1"), QString::number(range.numericData(0))); stream.writeAttribute(_("timing1"), QString::number(event.numericData(0)));
if (range.numericData(1) > 0) if (event.numericData(1) > 0)
stream.writeAttribute(_("timing2"), QString::number(range.numericData(1))); stream.writeAttribute(_("timing2"), QString::number(event.numericData(1)));
if (range.numericData(2) > 0) if (event.numericData(2) > 0)
stream.writeAttribute(_("timing3"), QString::number(range.numericData(2))); stream.writeAttribute(_("timing3"), QString::number(event.numericData(2)));
if (range.numericData(3) > 0) if (event.numericData(3) > 0)
stream.writeAttribute(_("timing4"), QString::number(range.numericData(3))); stream.writeAttribute(_("timing4"), QString::number(event.numericData(3)));
if (range.numericData(4) > 0) if (event.numericData(4) > 0)
stream.writeAttribute(_("timing5"), QString::number(range.numericData(4))); stream.writeAttribute(_("timing5"), QString::number(event.numericData(4)));
} }
// special: memory allocation event // special: memory allocation event
if (event.message == MemoryAllocation) if (type.message == MemoryAllocation)
stream.writeAttribute(_("amount"), QString::number(range.numericData(0))); stream.writeAttribute(_("amount"), QString::number(event.numericData(0)));
if (event.message == DebugMessage) if (type.message == DebugMessage)
stream.writeAttribute(_("text"), range.stringData()); stream.writeAttribute(_("text"), event.stringData());
stream.writeEndElement(); stream.writeEndElement();
incrementProgress(); incrementProgress();
@@ -657,7 +657,7 @@ void QmlProfilerFileWriter::save(QIODevice *device)
if (isCanceled()) if (isCanceled())
return; return;
const QmlProfilerDataModel::QmlEventNoteData &notes = m_notes[noteIndex]; const QmlNote &notes = m_notes[noteIndex];
stream.writeStartElement(_("note")); stream.writeStartElement(_("note"));
stream.writeAttribute(_("startTime"), QString::number(notes.startTime)); stream.writeAttribute(_("startTime"), QString::number(notes.startTime));
stream.writeAttribute(_("duration"), QString::number(notes.duration)); stream.writeAttribute(_("duration"), QString::number(notes.duration));

View File

@@ -56,26 +56,26 @@ public:
qint64 traceStart() const { return m_traceStart; } qint64 traceStart() const { return m_traceStart; }
qint64 traceEnd() const { return m_traceEnd; } qint64 traceEnd() const { return m_traceEnd; }
const QVector<QmlProfilerDataModel::QmlEventTypeData> &qmlEvents() const { return m_qmlEvents; } const QVector<QmlEventType> &eventTypes() const { return m_eventTypes; }
const QVector<QmlProfilerDataModel::QmlEventData> &ranges() const { return m_ranges; } const QVector<QmlEvent> &events() const { return m_events; }
const QVector<QmlProfilerDataModel::QmlEventNoteData> &notes() const { return m_notes; } const QVector<QmlNote> &notes() const { return m_notes; }
signals: signals:
void error(const QString &error); void error(const QString &error);
void success(); void success();
private: private:
void loadEventData(QXmlStreamReader &reader); void loadEventTypes(QXmlStreamReader &reader);
void loadProfilerDataModel(QXmlStreamReader &reader); void loadEvents(QXmlStreamReader &reader);
void loadNoteData(QXmlStreamReader &reader); void loadNotes(QXmlStreamReader &reader);
void progress(QIODevice *device); void progress(QIODevice *device);
bool isCanceled() const; bool isCanceled() const;
qint64 m_traceStart, m_traceEnd; qint64 m_traceStart, m_traceEnd;
QFutureInterface<void> *m_future; QFutureInterface<void> *m_future;
QVector<QmlProfilerDataModel::QmlEventTypeData> m_qmlEvents; QVector<QmlEventType> m_eventTypes;
QVector<QmlProfilerDataModel::QmlEventData> m_ranges; QVector<QmlEvent> m_events;
QVector<QmlProfilerDataModel::QmlEventNoteData> m_notes; QVector<QmlNote> m_notes;
quint64 m_loadedFeatures; quint64 m_loadedFeatures;
}; };
@@ -88,9 +88,8 @@ public:
explicit QmlProfilerFileWriter(QObject *parent = 0); explicit QmlProfilerFileWriter(QObject *parent = 0);
void setTraceTime(qint64 startTime, qint64 endTime, qint64 measturedTime); void setTraceTime(qint64 startTime, qint64 endTime, qint64 measturedTime);
void setQmlEvents(const QVector<QmlProfilerDataModel::QmlEventTypeData> &types, void setData(const QVector<QmlEventType> &types, const QVector<QmlEvent> &events);
const QVector<QmlProfilerDataModel::QmlEventData> &events); void setNotes(const QVector<QmlNote> &notes);
void setNotes(const QVector<QmlProfilerDataModel::QmlEventNoteData> &notes);
void setFuture(QFutureInterface<void> *future); void setFuture(QFutureInterface<void> *future);
void save(QIODevice *device); void save(QIODevice *device);
@@ -102,9 +101,9 @@ private:
qint64 m_startTime, m_endTime, m_measuredTime; qint64 m_startTime, m_endTime, m_measuredTime;
QFutureInterface<void> *m_future; QFutureInterface<void> *m_future;
QVector<QmlProfilerDataModel::QmlEventTypeData> m_qmlEvents; QVector<QmlEventType> m_eventTypes;
QVector<QmlProfilerDataModel::QmlEventData> m_ranges; QVector<QmlEvent> m_events;
QVector<QmlProfilerDataModel::QmlEventNoteData> m_notes; QVector<QmlNote> m_notes;
int m_newProgressValue; int m_newProgressValue;
}; };

View File

@@ -138,9 +138,9 @@ void SceneGraphTimelineModel::loadData()
return; return;
// combine the data of several eventtypes into two rows // combine the data of several eventtypes into two rows
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = simpleModel->getEventTypes(); const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { foreach (const QmlEvent &event, simpleModel->events()) {
const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex()]; const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type)) if (!accepted(type))
continue; continue;
@@ -220,7 +220,7 @@ void SceneGraphTimelineModel::loadData()
default: break; default: break;
} }
updateProgress(count(), simpleModel->getEvents().count()); updateProgress(count(), simpleModel->events().count());
} }
computeNesting(); computeNesting();