QmlProfiler: Unify event type definitions

Generally save both the Message and RangeType attributes so that we
avoid clashes between those types. Also keep all the types in one
place and make their names follow qtdeclarative's conventions.

Change-Id: I811bfcc4b72aaa2a0142babc92d96968ed2d4007
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-06-03 16:57:32 +02:00
parent 83df620612
commit 94722ec5e7
20 changed files with 285 additions and 230 deletions

View File

@@ -175,11 +175,13 @@ void QmlProfilerClientManager::connectClientSignals()
connect(d->qmlclientplugin.data(), SIGNAL(complete(qint64)),
this, SLOT(qmlComplete(qint64)));
connect(d->qmlclientplugin.data(),
SIGNAL(rangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
qint64,qint64,qint64,qint64,qint64)),
SIGNAL(rangedEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
QStringList,QmlDebug::QmlEventLocation,qint64,qint64,qint64,
qint64,qint64)),
d->modelManager,
SLOT(addQmlEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
qint64,qint64,qint64,qint64,qint64)));
SLOT(addQmlEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
QStringList,QmlDebug::QmlEventLocation,qint64,qint64,qint64,qint64,
qint64)));
connect(d->qmlclientplugin.data(), SIGNAL(traceFinished(qint64)),
d->modelManager->traceTime(), SLOT(setEndTime(qint64)));
connect(d->qmlclientplugin.data(), SIGNAL(traceStarted(qint64)),

View File

@@ -55,7 +55,7 @@ QString getInitialDetails(const QmlProfilerDataModel::QmlEventData &event);
QmlDebug::QmlEventLocation getLocation(const QmlProfilerDataModel::QmlEventData &event)
{
QmlDebug::QmlEventLocation eventLocation = event.location;
if ((event.eventType == QmlDebug::Creating || event.eventType == QmlDebug::Compiling)
if ((event.rangeType == QmlDebug::Creating || event.rangeType == QmlDebug::Compiling)
&& eventLocation.filename.isEmpty()) {
eventLocation.filename = getInitialDetails(event);
eventLocation.line = 1;
@@ -169,7 +169,7 @@ void QmlProfilerDataModel::complete()
// request further details from files
//
if (event->eventType != QmlDebug::Binding && event->eventType != QmlDebug::HandlingSignal)
if (event->rangeType != QmlDebug::Binding && event->rangeType != QmlDebug::HandlingSignal)
continue;
// This skips anonymous bindings in Qt4.8 (we don't have valid location data for them)
@@ -189,7 +189,8 @@ void QmlProfilerDataModel::complete()
QmlProfilerBaseModel::complete();
}
void QmlProfilerDataModel::addQmlEvent(int type, int bindingType, qint64 startTime,
void QmlProfilerDataModel::addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType,
int detailType, qint64 startTime,
qint64 duration, const QStringList &data,
const QmlDebug::QmlEventLocation &location,
qint64 ndata1, qint64 ndata2, qint64 ndata3,
@@ -197,7 +198,7 @@ void QmlProfilerDataModel::addQmlEvent(int type, int bindingType, qint64 startTi
{
Q_D(QmlProfilerDataModel);
QString displayName;
if (type == QmlDebug::Painting && bindingType == QmlDebug::AnimationFrame) {
if (message == QmlDebug::Event && detailType == QmlDebug::AnimationFrame) {
displayName = tr("Animations");
} else {
displayName = QString::fromLatin1("%1:%2").arg(
@@ -205,8 +206,8 @@ void QmlProfilerDataModel::addQmlEvent(int type, int bindingType, qint64 startTi
QString::number(location.line));
}
QmlEventData eventData = {displayName, type, bindingType, startTime, duration, data, location,
ndata1, ndata2, ndata3, ndata4, ndata5};
QmlEventData eventData = {displayName, message, rangeType, detailType, startTime, duration,
data, location, ndata1, ndata2, ndata3, ndata4, ndata5};
d->eventList.append(eventData);
d->modelManager->modelProxyCountUpdated(d->modelId, startTime,
@@ -219,8 +220,8 @@ QString QmlProfilerDataModel::getHashString(const QmlProfilerDataModel::QmlEvent
event.location.filename,
QString::number(event.location.line),
QString::number(event.location.column),
QString::number(event.eventType),
QString::number(event.bindingType));
QString::number((event.message << 8) | event.rangeType),
QString::number(event.detailType));
}
qint64 QmlProfilerDataModel::lastTimeMark() const

View File

@@ -30,6 +30,7 @@
#ifndef QMLPROFILERDATAMODEL_H
#define QMLPROFILERDATAMODEL_H
#include <qmldebug/qmlprofilereventtypes.h>
#include "qmlprofilerbasemodel.h"
namespace QmlProfiler {
@@ -40,8 +41,9 @@ class QMLPROFILER_EXPORT QmlProfilerDataModel : public QmlProfilerBaseModel
public:
struct QmlEventData {
QString displayName;
int eventType;
int bindingType;
QmlDebug::Message message;
QmlDebug::RangeType rangeType;
int detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType
qint64 startTime;
qint64 duration;
QStringList data;
@@ -60,9 +62,10 @@ public:
virtual void clear();
virtual bool isEmpty() const;
virtual void complete();
void addQmlEvent(int type, int bindingType, qint64 startTime, qint64 duration,
const QStringList &data, const QmlDebug::QmlEventLocation &location,
qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5);
void addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int bindingType,
qint64 startTime, qint64 duration, const QStringList &data,
const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2,
qint64 ndata3, qint64 ndata4, qint64 ndata5);
static QString getHashString(const QmlProfilerDataModel::QmlEventData &event);
qint64 lastTimeMark() const;

View File

@@ -58,7 +58,7 @@ public:
int modelId;
QList<QmlDebug::QmlEventType> acceptedTypes;
QList<QmlDebug::RangeType> acceptedTypes;
QSet<QString> eventsInBindingLoop;
};
@@ -80,7 +80,7 @@ QmlProfilerEventsModelProxy::~QmlProfilerEventsModelProxy()
delete d;
}
void QmlProfilerEventsModelProxy::setEventTypeAccepted(QmlDebug::QmlEventType type, bool accepted)
void QmlProfilerEventsModelProxy::setEventTypeAccepted(QmlDebug::RangeType type, bool accepted)
{
if (accepted && !d->acceptedTypes.contains(type))
d->acceptedTypes << type;
@@ -88,7 +88,7 @@ void QmlProfilerEventsModelProxy::setEventTypeAccepted(QmlDebug::QmlEventType ty
d->acceptedTypes.removeOne(type);
}
bool QmlProfilerEventsModelProxy::eventTypeAccepted(QmlDebug::QmlEventType type) const
bool QmlProfilerEventsModelProxy::eventTypeAccepted(QmlDebug::RangeType type) const
{
return d->acceptedTypes.contains(type);
}
@@ -144,7 +144,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
for (int i = 0; i < eventList.size(); ++i) {
const QmlProfilerDataModel::QmlEventData *event = &eventList[i];
if (!d->acceptedTypes.contains((QmlDebug::QmlEventType)event->eventType))
if (!d->acceptedTypes.contains(event->rangeType))
continue;
if (checkRanges) {
@@ -161,8 +161,9 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
hash,
event->data.join(QLatin1String(" ")),
event->location,
event->eventType,
event->bindingType,
event->message,
event->rangeType,
event->detailType,
event->duration,
1, //calls
event->duration, //minTime
@@ -257,7 +258,8 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
rootEventName, // hash
tr("Main Program"), //event.details,
rootEventLocation, // location
(int)QmlDebug::Binding, // event type
QmlDebug::MaximumMessage,
QmlDebug::Binding, // event type
0, // binding type
qmlTime + 1,
1, //calls
@@ -347,6 +349,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
QString rootEventName = tr("<program>");
QmlProfilerDataModel::QmlEventData rootEvent = {
rootEventName,
QmlDebug::MaximumMessage,
QmlDebug::Binding,
0,
0,
@@ -370,7 +373,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
// whitelist
if (!m_eventsModel->eventTypeAccepted((QmlDebug::QmlEventType)event.eventType))
if (!m_eventsModel->eventTypeAccepted(event.rangeType))
continue;
// level computation
@@ -407,7 +410,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
m_data[eventHash].insert(parentHash, QmlEventRelativesData());
QmlEventRelativesData *parent = &(m_data[eventHash][parentHash]);
parent->displayName = parentEvent->displayName;
parent->eventType = parentEvent->eventType;
parent->rangeType = parentEvent->rangeType;
parent->duration = event.duration;
parent->calls = 1;
parent->details = parentEvent->data.join(QLatin1String(""));
@@ -450,7 +453,7 @@ void QmlProfilerEventChildrenModelProxy::loadData()
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
// whitelist
if (!m_eventsModel->eventTypeAccepted((QmlDebug::QmlEventType)event.eventType))
if (!m_eventsModel->eventTypeAccepted(event.rangeType))
continue;
// level computation
@@ -480,7 +483,7 @@ void QmlProfilerEventChildrenModelProxy::loadData()
m_data[parentHash].insert(eventHash, QmlEventRelativesData());
QmlEventRelativesData *child = &(m_data[parentHash][eventHash]);
child->displayName = event.displayName;
child->eventType = event.eventType;
child->rangeType = event.rangeType;
child->duration = event.duration;
child->calls = 1;
child->details = event.data.join(QLatin1String(""));

View File

@@ -53,7 +53,8 @@ public:
QString eventHashStr;
QString details;
QmlDebug::QmlEventLocation location;
int eventType;
QmlDebug::Message message;
QmlDebug::RangeType rangeType;
int bindingType;
qint64 duration;
@@ -70,8 +71,8 @@ public:
QmlProfilerEventsModelProxy(QmlProfilerModelManager *modelManager, QObject *parent = 0);
~QmlProfilerEventsModelProxy();
void setEventTypeAccepted(QmlDebug::QmlEventType type, bool accepted);
bool eventTypeAccepted(QmlDebug::QmlEventType) const;
void setEventTypeAccepted(QmlDebug::RangeType type, bool accepted);
bool eventTypeAccepted(QmlDebug::RangeType) const;
const QList<QmlEventStats> getData() const;
int count() const;
@@ -104,7 +105,7 @@ class QmlProfilerEventRelativesModelProxy : public QObject
public:
struct QmlEventRelativesData {
QString displayName;
int eventType;
QmlDebug::RangeType rangeType;
qint64 duration;
qint64 calls;
QString details;

View File

@@ -561,9 +561,9 @@ void QmlProfilerEventsMainView::parseModelProxy()
newRow << new EventsViewItem(event.displayName);
if (d->m_fieldShown[Type]) {
QString typeString = QmlProfilerEventsMainView::nameForType(event.eventType);
QString typeString = QmlProfilerEventsMainView::nameForType(event.rangeType);
QString toolTipText;
if (event.eventType == Binding) {
if (event.rangeType == Binding) {
if (event.bindingType == (int)OptimizedBinding) {
typeString = typeString + QLatin1Char(' ') + tr("(Opt)");
toolTipText = tr("Binding is evaluated by the optimized engine.");
@@ -645,17 +645,17 @@ void QmlProfilerEventsMainView::parseModelProxy()
}
}
QString QmlProfilerEventsMainView::nameForType(int typeNumber)
QString QmlProfilerEventsMainView::nameForType(QmlDebug::RangeType typeNumber)
{
switch (typeNumber) {
case 0: return QmlProfilerEventsMainView::tr("Paint");
case 1: return QmlProfilerEventsMainView::tr("Compile");
case 2: return QmlProfilerEventsMainView::tr("Create");
case 3: return QmlProfilerEventsMainView::tr("Binding");
case 4: return QmlProfilerEventsMainView::tr("Signal");
case 5: return QmlProfilerEventsMainView::tr("JavaScript");
case QmlDebug::Painting: return QmlProfilerEventsMainView::tr("Paint");
case QmlDebug::Compiling: return QmlProfilerEventsMainView::tr("Compile");
case QmlDebug::Creating: return QmlProfilerEventsMainView::tr("Create");
case QmlDebug::Binding: return QmlProfilerEventsMainView::tr("Binding");
case QmlDebug::HandlingSignal: return QmlProfilerEventsMainView::tr("Signal");
case QmlDebug::Javascript: return QmlProfilerEventsMainView::tr("JavaScript");
default: return QString();
}
return QString();
}
void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
@@ -867,7 +867,7 @@ void QmlProfilerEventRelativesView::rebuildTree(QmlProfilerEventRelativesModelPr
// maybe we should store the data in this proxy and get it here
// no indirections at this level of abstraction!
newRow << new EventsViewItem(event.displayName);
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.eventType));
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.rangeType));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration));
newRow << new EventsViewItem(QString::number(event.calls));
newRow << new EventsViewItem(event.details);

View File

@@ -119,7 +119,7 @@ public:
void copyTableToClipboard() const;
void copyRowToClipboard() const;
static QString nameForType(int typeNumber);
static QString nameForType(QmlDebug::RangeType typeNumber);
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
QString selectedEventHash() const;

View File

@@ -249,8 +249,9 @@ void QmlProfilerModelManager::newTimeEstimation(qint64 estimation)
d->estimatedTime = estimation;
}
void QmlProfilerModelManager::addQmlEvent(int type,
int bindingType,
void QmlProfilerModelManager::addQmlEvent(QmlDebug::Message message,
QmlDebug::RangeType rangeType,
int detailType,
qint64 startTime,
qint64 length,
const QStringList &data,
@@ -266,7 +267,8 @@ void QmlProfilerModelManager::addQmlEvent(int type,
d->traceTime->setStartTime(startTime);
QTC_ASSERT(state() == QmlProfilerDataState::AcquiringData, /**/);
d->model->addQmlEvent(type, bindingType, startTime, length, data, location, ndata1, ndata2, ndata3, ndata4, ndata5);
d->model->addQmlEvent(message, rangeType, detailType, startTime, length, data, location,
ndata1, ndata2, ndata3, ndata4, ndata5);
}
void QmlProfilerModelManager::addV8Event(int depth, const QString &function, const QString &filename,
@@ -353,10 +355,12 @@ void QmlProfilerModelManager::load()
QmlProfilerFileReader reader;
connect(&reader, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
connect(&reader, SIGNAL(rangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
connect(&reader, SIGNAL(rangedEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
QStringList,QmlDebug::QmlEventLocation,
qint64, qint64, qint64, qint64, qint64)),
this, SLOT(addQmlEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
qint64, qint64, qint64, qint64, qint64)));
this, SLOT(addQmlEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
QStringList,QmlDebug::QmlEventLocation,
qint64, qint64, qint64, qint64, qint64)));
connect(&reader, SIGNAL(traceStartTime(qint64)), traceTime(), SLOT(setStartTime(qint64)));
connect(&reader, SIGNAL(traceEndTime(qint64)), traceTime(), SLOT(setEndTime(qint64)));
reader.setV8DataModel(d->v8Model);

View File

@@ -33,6 +33,7 @@
#include "qmlprofiler_global.h"
#include <qmldebug/qmlprofilereventlocation.h>
#include <qmldebug/qmlprofilereventtypes.h>
#include <utils/fileinprojectfinder.h>
#include <QObject>
@@ -138,8 +139,9 @@ public slots:
void clear();
void prepareForWriting();
void addQmlEvent(int type, int bindingType, qint64 startTime, qint64 length,
const QStringList &data, const QmlDebug::QmlEventLocation &location,
void addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int bindingType,
qint64 startTime, qint64 length, const QStringList &data,
const QmlDebug::QmlEventLocation &location,
qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5);
void addV8Event(int depth, const QString &function,const QString &filename, int lineNumber,
double totalTime, double selfTime);

View File

@@ -63,7 +63,7 @@ private:
PaintEventsModelProxy::PaintEventsModelProxy(QObject *parent)
: SingleCategoryTimelineModel(new PaintEventsModelProxyPrivate,
QLatin1String("PaintEventsModelProxy"), tr("Painting"),
QmlDebug::Painting, parent)
QmlDebug::Event, QmlDebug::MaximumRangeType, parent)
{
Q_D(PaintEventsModelProxy);
d->seenForeignPaintEvent = false;
@@ -84,7 +84,7 @@ void PaintEventsModelProxy::clear()
bool PaintEventsModelProxy::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
return SingleCategoryTimelineModel::eventAccepted(event) &&
event.bindingType == QmlDebug::AnimationFrame;
event.detailType== QmlDebug::AnimationFrame;
}
void PaintEventsModelProxy::loadData()
@@ -103,7 +103,7 @@ void PaintEventsModelProxy::loadData()
foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) {
if (!eventAccepted(event)) {
if (event.eventType == QmlDebug::Painting)
if (event.rangeType == QmlDebug::Painting)
d->seenForeignPaintEvent = true;
continue;
}

View File

@@ -92,7 +92,7 @@ void BasicTimelineModel::clear()
void BasicTimelineModel::BasicTimelineModelPrivate::prepare()
{
categorySpan.clear();
for (int i = 0; i < QmlDebug::MaximumQmlEventType; i++) {
for (int i = 0; i < QmlDebug::MaximumRangeType; i++) {
CategorySpan newCategory = {false, 1, 1, i};
categorySpan << newCategory;
}
@@ -100,11 +100,8 @@ void BasicTimelineModel::BasicTimelineModelPrivate::prepare()
bool BasicTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
// only accept Qt4.x Painting events
if (event.eventType == QmlDebug::Painting)
return (event.bindingType == QmlDebug::QPainterEvent);
return (event.eventType <= QmlDebug::Javascript);
// Accept all range types. Qt5 paint events aren't ranges
return (event.rangeType != QmlDebug::MaximumRangeType);
}
void BasicTimelineModel::loadData()
@@ -126,7 +123,7 @@ void BasicTimelineModel::loadData()
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
if (!eventAccepted(event))
continue;
if (event.eventType == QmlDebug::Painting)
if (event.rangeType == QmlDebug::Painting)
d->seenPaintEvent = true;
QString eventHash = QmlProfilerDataModel::getHashString(event);
@@ -139,7 +136,7 @@ void BasicTimelineModel::loadData()
event.displayName,
event.data.join(QLatin1String(" ")),
event.location,
(QmlDebug::QmlEventType)event.eventType,
event.rangeType,
lastEventId++ // event id
};
d->eventDict << rangeEventData;
@@ -190,7 +187,7 @@ void BasicTimelineModel::BasicTimelineModelPrivate::computeNestingContracted()
QList<int> nestingLevels;
QList< QHash<int, qint64> > endtimesPerNestingLevel;
for (i = 0; i < QmlDebug::MaximumQmlEventType; i++) {
for (i = 0; i < QmlDebug::MaximumRangeType; i++) {
nestingLevels << QmlDebug::Constants::QML_MIN_LEVEL;
QHash<int, qint64> dummyHash;
dummyHash[QmlDebug::Constants::QML_MIN_LEVEL] = 0;
@@ -247,8 +244,8 @@ void BasicTimelineModel::BasicTimelineModelPrivate::findBindingLoops()
BasicTimelineModel::QmlRangeEventData data = eventDict.at(event->eventId);
static QVector<QmlDebug::QmlEventType> acceptedTypes =
QVector<QmlDebug::QmlEventType>() << QmlDebug::Binding << QmlDebug::HandlingSignal;
static QVector<QmlDebug::RangeType> acceptedTypes =
QVector<QmlDebug::RangeType>() << QmlDebug::Binding << QmlDebug::HandlingSignal;
if (!acceptedTypes.contains(data.eventType))
continue;

View File

@@ -53,7 +53,7 @@ public:
QString displayName;
QString details;
QmlDebug::QmlEventLocation location;
QmlDebug::QmlEventType eventType;
QmlDebug::RangeType eventType;
int eventId; // separate
};

View File

@@ -43,17 +43,33 @@ using namespace QmlDebug;
const char PROFILER_FILE_VERSION[] = "1.02";
const char TYPE_PAINTING_STR[] = "Painting";
const char TYPE_COMPILING_STR[] = "Compiling";
const char TYPE_CREATING_STR[] = "Creating";
const char TYPE_BINDING_STR[] = "Binding";
const char TYPE_HANDLINGSIGNAL_STR[] = "HandlingSignal";
const char TYPE_PIXMAPCACHE_STR[] = "PixmapCache";
const char TYPE_SCENEGRAPH_STR[] = "SceneGraph";
static const char *RANGE_TYPE_STRINGS[] = {
"Painting",
"Compiling",
"Creating",
"Binding",
"HandlingSignal",
"Javascript"
};
Q_STATIC_ASSERT(sizeof(RANGE_TYPE_STRINGS) == QmlDebug::MaximumRangeType * sizeof(const char *));
static const char *MESSAGE_STRINGS[] = {
// So far only pixmap and scenegraph are used. The others are padding.
"Event",
"RangeStart",
"RangeData",
"RangeLocation",
"RangeEnd",
"Complete",
"PixmapCache",
"SceneGraph"
};
Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == QmlDebug::MaximumMessage * sizeof(const char *));
#define _(X) QLatin1String(X)
//
// "be strict in your output but tolerant in your inputs"
//
@@ -61,59 +77,44 @@ const char TYPE_SCENEGRAPH_STR[] = "SceneGraph";
namespace QmlProfiler {
namespace Internal {
static QmlEventType qmlEventTypeAsEnum(const QString &typeString)
static QPair<QmlDebug::Message, QmlDebug::RangeType> qmlTypeAsEnum(const QString &typeString)
{
if (typeString == _(TYPE_PAINTING_STR)) {
return Painting;
} else if (typeString == _(TYPE_COMPILING_STR)) {
return Compiling;
} else if (typeString == _(TYPE_CREATING_STR)) {
return Creating;
} else if (typeString == _(TYPE_BINDING_STR)) {
return Binding;
} else if (typeString == _(TYPE_HANDLINGSIGNAL_STR)) {
return HandlingSignal;
} else if (typeString == _(TYPE_PIXMAPCACHE_STR)) {
return PixmapCacheEvent;
} else if (typeString == _(TYPE_SCENEGRAPH_STR)) {
return SceneGraphFrameEvent;
} else {
QPair<QmlDebug::Message, QmlDebug::RangeType> ret(QmlDebug::MaximumMessage,
QmlDebug::MaximumRangeType);
for (int i = 0; i < QmlDebug::MaximumMessage; ++i) {
if (typeString == _(MESSAGE_STRINGS[i])) {
ret.first = static_cast<QmlDebug::Message>(i);
break;
}
}
for (int i = 0; i < QmlDebug::MaximumRangeType; ++i) {
if (typeString == _(RANGE_TYPE_STRINGS[i])) {
ret.second = static_cast<QmlDebug::RangeType>(i);
break;
}
}
if (ret.first == QmlDebug::MaximumMessage && ret.second == QmlDebug::MaximumRangeType) {
bool isNumber = false;
int type = typeString.toUInt(&isNumber);
if (isNumber)
return (QmlEventType)type;
else
return MaximumQmlEventType;
if (isNumber && type < QmlDebug::MaximumRangeType)
// Allow saving ranges as numbers, but not messages.
ret.second = static_cast<QmlDebug::RangeType>(type);
}
return ret;
}
static QString qmlEventTypeAsString(QmlEventType typeEnum)
static QString qmlTypeAsString(QmlDebug::Message message, QmlDebug::RangeType rangeType)
{
switch (typeEnum) {
case Painting:
return _(TYPE_PAINTING_STR);
break;
case Compiling:
return _(TYPE_COMPILING_STR);
break;
case Creating:
return _(TYPE_CREATING_STR);
break;
case Binding:
return _(TYPE_BINDING_STR);
break;
case HandlingSignal:
return _(TYPE_HANDLINGSIGNAL_STR);
break;
case PixmapCacheEvent:
return _(TYPE_PIXMAPCACHE_STR);
break;
case SceneGraphFrameEvent:
return _(TYPE_SCENEGRAPH_STR);
break;
default:
return QString::number((int)typeEnum);
}
if (rangeType < QmlDebug::MaximumRangeType)
return _(RANGE_TYPE_STRINGS[rangeType]);
else if (message != QmlDebug::MaximumMessage)
return _(MESSAGE_STRINGS[message]);
else
return QString::number((int)rangeType);
}
@@ -195,6 +196,7 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
QString(), // displayname
QString(), // filename
QString(), // details
MaximumMessage,
Painting, // type
QmlBinding, // bindingType, set for backwards compatibility
0, // line
@@ -233,7 +235,9 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
}
if (elementName == _("type")) {
event.type = qmlEventTypeAsEnum(readData);
QPair<QmlDebug::Message, QmlDebug::RangeType> enums = qmlTypeAsEnum(readData);
event.message = enums.first;
event.rangeType = enums.second;
break;
}
@@ -257,11 +261,23 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream)
break;
}
if (elementName == _("animationFrame")) {
event.detailType = readData.toInt();
// 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
// confusing), even though they clearly aren't ranges. Convert that to something
// sane here.
if (event.detailType == 4) {
event.message = Event;
event.rangeType = MaximumRangeType;
event.detailType = AnimationFrame;
}
}
if (elementName == _("bindingType") ||
elementName == _("animationFrame") ||
elementName == _("cacheEventType") ||
elementName == _("sgEventType")) {
event.bindingType = readData.toInt();
event.detailType = readData.toInt();
break;
}
@@ -370,10 +386,11 @@ void QmlProfilerFileReader::processQmlEvents()
QmlEvent &event = m_qmlEvents[eventIndex];
emit rangedEvent(event.type, event.bindingType, range.startTime, range.duration,
QStringList(event.details),
emit rangedEvent(event.message, event.rangeType, event.detailType, range.startTime,
range.duration, QStringList(event.details),
QmlEventLocation(event.filename, event.line, event.column),
range.numericData1,range.numericData2, range.numericData3, range.numericData4, range.numericData5);
range.numericData1,range.numericData2, range.numericData3,
range.numericData4, range.numericData5);
}
}
@@ -385,7 +402,9 @@ QmlProfilerFileWriter::QmlProfilerFileWriter(QObject *parent) :
m_measuredTime(0),
m_v8Model(0)
{
m_acceptedTypes << QmlDebug::Compiling << QmlDebug::Creating << QmlDebug::Binding << QmlDebug::HandlingSignal;
m_acceptedRangeTypes << QmlDebug::Compiling << QmlDebug::Creating << QmlDebug::Binding
<< QmlDebug::HandlingSignal << QmlDebug::Javascript;
m_acceptedMessages << QmlDebug::SceneGraphFrame << QmlDebug::PixmapCacheEvent;
}
void QmlProfilerFileWriter::setTraceTime(qint64 startTime, qint64 endTime, qint64 measuredTime)
@@ -405,14 +424,16 @@ void QmlProfilerFileWriter::setQmlEvents(const QVector<QmlProfilerDataModel::Qml
foreach (const QmlProfilerDataModel::QmlEventData &event, events) {
const QString hashStr = QmlProfilerDataModel::getHashString(event);
if (!m_qmlEvents.contains(hashStr)) {
QmlEvent e = { event.displayName,
event.location.filename,
event.data.join(_("")),
static_cast<QmlDebug::QmlEventType>(event.eventType),
event.bindingType,
event.location.line,
event.location.column
};
QmlEvent e = {
event.displayName,
event.location.filename,
event.data.join(_("")),
event.message,
event.rangeType,
event.detailType,
event.location.line,
event.location.column
};
m_qmlEvents.insert(hashStr, e);
}
@@ -451,21 +472,21 @@ void QmlProfilerFileWriter::save(QIODevice *device)
stream.writeStartElement(_("event"));
stream.writeAttribute(_("index"), keys[eventIter.key()]);
stream.writeTextElement(_("displayname"), event.displayName);
stream.writeTextElement(_("type"), qmlEventTypeAsString(event.type));
stream.writeTextElement(_("type"), qmlTypeAsString(event.message, event.rangeType));
if (!event.filename.isEmpty()) {
stream.writeTextElement(_("filename"), event.filename);
stream.writeTextElement(_("line"), QString::number(event.line));
stream.writeTextElement(_("column"), QString::number(event.column));
}
stream.writeTextElement(_("details"), event.details);
if (event.type == Binding)
stream.writeTextElement(_("bindingType"), QString::number(event.bindingType));
if (event.type == Painting && event.bindingType == AnimationFrame)
stream.writeTextElement(_("animationFrame"), QString::number(event.bindingType));
if (event.type == PixmapCacheEvent)
stream.writeTextElement(_("cacheEventType"), QString::number(event.bindingType));
if (event.type == SceneGraphFrameEvent)
stream.writeTextElement(_("sgEventType"), QString::number(event.bindingType));
if (event.rangeType == Binding)
stream.writeTextElement(_("bindingType"), QString::number(event.detailType));
if (event.message == Event && event.detailType == AnimationFrame)
stream.writeTextElement(_("animationFrame"), QString::number(event.detailType));
if (event.message == PixmapCacheEvent)
stream.writeTextElement(_("cacheEventType"), QString::number(event.detailType));
if (event.message == SceneGraphFrame)
stream.writeTextElement(_("sgEventType"), QString::number(event.detailType));
stream.writeEndElement();
}
stream.writeEndElement(); // eventData
@@ -486,27 +507,25 @@ void QmlProfilerFileWriter::save(QIODevice *device)
QmlEvent event = m_qmlEvents.value(eventHash);
// special: animation event
if (event.type == QmlDebug::Painting && event.bindingType == QmlDebug::AnimationFrame) {
if (event.message == QmlDebug::Event && event.detailType == QmlDebug::AnimationFrame) {
stream.writeAttribute(_("framerate"), QString::number(range.numericData1));
stream.writeAttribute(_("animationcount"), QString::number(range.numericData2));
stream.writeAttribute(_("thread"), QString::number(range.numericData3));
}
// special: pixmap cache event
if (event.type == QmlDebug::PixmapCacheEvent) {
// pixmap image size
if (event.bindingType == 0) {
if (event.message == QmlDebug::PixmapCacheEvent) {
if (event.detailType == PixmapSizeKnown) {
stream.writeAttribute(_("width"), QString::number(range.numericData1));
stream.writeAttribute(_("height"), QString::number(range.numericData2));
}
// reference count (1) / cache size changed (2)
if (event.bindingType == 1 || event.bindingType == 2)
if (event.detailType == PixmapReferenceCountChanged ||
event.detailType == PixmapCacheCountChanged)
stream.writeAttribute(_("refCount"), QString::number(range.numericData3));
}
if (event.type == QmlDebug::SceneGraphFrameEvent) {
if (event.message == QmlDebug::SceneGraphFrame) {
// special: scenegraph frame events
if (range.numericData1 > 0)
stream.writeAttribute(_("timing1"), QString::number(range.numericData1));
@@ -542,7 +561,8 @@ void QmlProfilerFileWriter::calculateMeasuredTime(const QVector<QmlProfilerDataM
foreach (const QmlProfilerDataModel::QmlEventData &event, events) {
// whitelist
if (!m_acceptedTypes.contains(event.eventType))
if (!m_acceptedRangeTypes.contains(event.rangeType) &&
!m_acceptedMessages.contains(event.message))
continue;
// level computation

View File

@@ -52,8 +52,9 @@ struct QmlEvent {
QString displayName;
QString filename;
QString details;
QmlDebug::QmlEventType type;
int bindingType;
QmlDebug::Message message;
QmlDebug::RangeType rangeType;
int detailType;
int line;
int column;
};
@@ -85,8 +86,9 @@ signals:
void traceStartTime(qint64 traceStartTime);
void traceEndTime(qint64 traceStartTime);
void rangedEvent(int type, int bindingType, qint64 startTime, qint64 length,
const QStringList &data, const QmlDebug::QmlEventLocation &location,
void rangedEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int detailType,
qint64 startTime, qint64 length, const QStringList &data,
const QmlDebug::QmlEventLocation &location,
qint64 param1, qint64 param2, qint64 param3, qint64 param4, qint64 param5);
void error(const QString &error);
@@ -124,7 +126,8 @@ private:
QV8ProfilerDataModel *m_v8Model;
QHash<QString,QmlEvent> m_qmlEvents;
QVector<QPair<Range, QString> > m_ranges;
QVector <int> m_acceptedTypes;
QVector<QmlDebug::RangeType> m_acceptedRangeTypes;
QVector<QmlDebug::Message> m_acceptedMessages;
};

View File

@@ -33,14 +33,15 @@
namespace QmlProfiler {
SingleCategoryTimelineModel::SingleCategoryTimelineModel(SingleCategoryTimelineModelPrivate *dd,
const QString &name, const QString &label, QmlDebug::QmlEventType eventType,
QObject *parent) :
const QString &name, const QString &label, QmlDebug::Message message,
QmlDebug::RangeType rangeType, QObject *parent) :
AbstractTimelineModel(dd, name, parent)
{
Q_D(SingleCategoryTimelineModel);
d->expanded = false;
d->label = label;
d->eventType = eventType;
d->message = message;
d->rangeType = rangeType;
}
/////////////////// QML interface
@@ -48,7 +49,7 @@ SingleCategoryTimelineModel::SingleCategoryTimelineModel(SingleCategoryTimelineM
bool SingleCategoryTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
Q_D(const SingleCategoryTimelineModel);
return (event.eventType == d->eventType);
return (event.rangeType == d->rangeType && event.message == d->message);
}
bool SingleCategoryTimelineModel::expanded(int categoryIndex) const
@@ -84,7 +85,7 @@ int SingleCategoryTimelineModel::getEventType(int index) const
{
Q_D(const SingleCategoryTimelineModel);
Q_UNUSED(index);
return (int)d->eventType;
return (d->message << 8) + d->rangeType;
}
int SingleCategoryTimelineModel::getEventCategory(int index) const

View File

@@ -52,8 +52,8 @@ public:
protected:
class SingleCategoryTimelineModelPrivate;
SingleCategoryTimelineModel(SingleCategoryTimelineModelPrivate *dd, const QString &name,
const QString &label, QmlDebug::QmlEventType eventType,
QObject *parent);
const QString &label, QmlDebug::Message message,
QmlDebug::RangeType rangeType, QObject *parent);
Q_DECLARE_PRIVATE(SingleCategoryTimelineModel)
};

View File

@@ -40,7 +40,8 @@ class SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate :
public:
bool expanded;
QString label;
QmlDebug::QmlEventType eventType;
QmlDebug::Message message;
QmlDebug::RangeType rangeType;
};
}