Commit 9ca42dac authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Don't process all events twice when loading traces



At the end of QmlProfilerFileReader::load() we have a perfectly valid
set of types and events which we can just pass on to the model as-is.

Change-Id: I6981663f409c4647f4d5ae8a73b5d14cc701017b
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent ce49f92c
......@@ -126,6 +126,18 @@ const QVector<QmlProfilerDataModel::QmlEventTypeData> &QmlProfilerDataModel::get
return d->eventTypes;
}
void QmlProfilerDataModel::setData(const QVector<QmlProfilerDataModel::QmlEventTypeData> &types,
const QVector<QmlProfilerDataModel::QmlEventData> &events)
{
Q_D(QmlProfilerDataModel);
d->eventList = events;
d->eventTypes = types;
for (int id = 0; id < types.count(); ++id)
d->eventTypeIds[types[id]] = id;
// Half the work is done. complete() will do the rest.
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2);
}
int QmlProfilerDataModel::count() const
{
Q_D(const QmlProfilerDataModel);
......
......@@ -63,6 +63,8 @@ public:
const QVector<QmlEventData> &getEvents() const;
const QVector<QmlEventTypeData> &getEventTypes() const;
void setData(const QVector<QmlEventTypeData> &types, const QVector<QmlEventData> &events);
int count() const;
virtual void clear();
virtual bool isEmpty() const;
......
......@@ -367,15 +367,10 @@ void QmlProfilerModelManager::load()
QmlProfilerFileReader reader;
connect(&reader, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
connect(&reader, SIGNAL(rangedEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
QString,QmlDebug::QmlEventLocation,
qint64, qint64, qint64, qint64, qint64)),
this, SLOT(addQmlEvent(QmlDebug::Message,QmlDebug::RangeType,int,qint64,qint64,
QString,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);
reader.setQmlDataModel(d->model);
reader.load(&file);
complete();
......
......@@ -130,6 +130,11 @@ void QmlProfilerFileReader::setV8DataModel(QV8ProfilerDataModel *dataModel)
m_v8Model = dataModel;
}
void QmlProfilerFileReader::setQmlDataModel(QmlProfilerDataModel *dataModel)
{
m_qmlModel = dataModel;
}
bool QmlProfilerFileReader::load(QIODevice *device)
{
QXmlStreamReader stream(device);
......@@ -180,8 +185,7 @@ bool QmlProfilerFileReader::load(QIODevice *device)
emit error(tr("Error while parsing trace data file: %1").arg(stream.errorString()));
return false;
} else {
processQmlEvents();
m_qmlModel->setData(m_qmlEvents, m_ranges);
return true;
}
}
......@@ -372,28 +376,6 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream)
}
}
void QmlProfilerFileReader::processQmlEvents()
{
for (int i = 0; i < m_ranges.size(); ++i) {
const QmlProfilerDataModel::QmlEventData &range = m_ranges[i];
int eventIndex = range.typeIndex;
if (eventIndex < 0 || eventIndex >= m_qmlEvents.size()) {
qWarning() << ".qtd file - range index" << eventIndex
<< "is outside of bounds (0, " << m_qmlEvents.size() << ")";
continue;
}
const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[eventIndex];
emit rangedEvent(event.message, event.rangeType, event.detailType, range.startTime,
range.duration, event.data, event.location,
range.numericData1,range.numericData2, range.numericData3,
range.numericData4, range.numericData5);
}
}
QmlProfilerFileWriter::QmlProfilerFileWriter(QObject *parent) :
QObject(parent),
m_startTime(0),
......
......@@ -55,6 +55,7 @@ public:
explicit QmlProfilerFileReader(QObject *parent = 0);
void setV8DataModel(QV8ProfilerDataModel *dataModel);
void setQmlDataModel(QmlProfilerDataModel *dataModel);
bool load(QIODevice *device);
......@@ -62,20 +63,14 @@ signals:
void traceStartTime(qint64 traceStartTime);
void traceEndTime(qint64 traceStartTime);
void rangedEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int detailType,
qint64 startTime, qint64 length, const QString &data,
const QmlDebug::QmlEventLocation &location,
qint64 param1, qint64 param2, qint64 param3, qint64 param4, qint64 param5);
void error(const QString &error);
private:
void loadEventData(QXmlStreamReader &reader);
void loadProfilerDataModel(QXmlStreamReader &reader);
void processQmlEvents();
QV8ProfilerDataModel *m_v8Model;
QmlProfilerDataModel *m_qmlModel;
QVector<QmlProfilerDataModel::QmlEventTypeData> m_qmlEvents;
QVector<QmlProfilerDataModel::QmlEventData> m_ranges;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment