QmlProfiler: Load data event by event in aggregated models

This paves the way for driving the event loading from the model
manager. Also, unify the loading and eliminate the two different
classes for the children models.

Change-Id: Ic89e757963292d75b3b6fd7d6012f09194dff5a9
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Ulf Hermann
2016-04-26 16:38:56 +02:00
parent bc18fafffd
commit dd87df7e5d
6 changed files with 265 additions and 303 deletions

View File

@@ -37,6 +37,12 @@
namespace QmlProfiler {
class QmlProfilerModelManager;
class QmlProfilerStatisticsRelativesModel;
enum QmlProfilerStatisticsRelation {
QmlProfilerStatisticsChilden,
QmlProfilerStatisticsParents
};
class QmlProfilerStatisticsModel : public QObject
{
@@ -63,7 +69,6 @@ public:
~QmlProfilerStatisticsModel();
void setEventTypeAccepted(RangeType type, bool accepted);
bool eventTypeAccepted(RangeType) const;
const QHash<int, QmlEventStats> &getData() const;
const QVector<QmlEventType> &getTypes() const;
@@ -73,6 +78,8 @@ public:
void clear();
void limitToRange(qint64 rangeStart, qint64 rangeEnd);
void setRelativesModel(QmlProfilerStatisticsRelativesModel *childModel,
QmlProfilerStatisticsRelation relation);
signals:
void dataAvailable();
@@ -80,7 +87,8 @@ signals:
private:
void loadData(qint64 rangeStart = -1, qint64 rangeEnd = -1);
const QSet<int> &eventsInBindingLoop() const;
void loadEvent(const QmlEvent &event, const QmlEventType &type);
void finalize();
private slots:
void dataChanged();
@@ -89,15 +97,13 @@ private slots:
private:
class QmlProfilerStatisticsModelPrivate;
QmlProfilerStatisticsModelPrivate *d;
friend class QmlProfilerStatisticsParentsModel;
friend class QmlProfilerStatisticsChildrenModel;
};
class QmlProfilerStatisticsRelativesModel : public QObject
{
Q_OBJECT
public:
struct QmlStatisticsRelativesData {
qint64 duration;
qint64 calls;
@@ -107,6 +113,7 @@ public:
QmlProfilerStatisticsRelativesModel(QmlProfilerModelManager *modelManager,
QmlProfilerStatisticsModel *statisticsModel,
QmlProfilerStatisticsRelation relation,
QObject *parent = 0);
int count() const;
@@ -115,42 +122,23 @@ public:
const QmlStatisticsRelativesMap &getData(int typeId) const;
const QVector<QmlEventType> &getTypes() const;
protected:
virtual void loadData() = 0;
void loadEvent(const QmlEvent &event);
void finalize(const QSet<int> &eventsInBindingLoop);
signals:
void dataAvailable();
protected slots:
void dataChanged();
protected:
QHash <int, QmlStatisticsRelativesMap> m_data;
QmlProfilerModelManager *m_modelManager;
QmlProfilerStatisticsModel *m_statisticsModel;
// for level computation
QHash<int, qint64> m_endtimesPerLevel;
int m_level = Constants::QML_MIN_LEVEL;
// compute parent-child relationship and call count
QHash<int, int> m_lastParent;
const QmlProfilerStatisticsRelation m_relation;
};
class QmlProfilerStatisticsParentsModel : public QmlProfilerStatisticsRelativesModel
{
Q_OBJECT
public:
QmlProfilerStatisticsParentsModel(QmlProfilerModelManager *modelManager,
QmlProfilerStatisticsModel *statisticsModel,
QObject *parent = 0);
protected:
virtual void loadData();
};
class QmlProfilerStatisticsChildrenModel : public QmlProfilerStatisticsRelativesModel
{
Q_OBJECT
public:
QmlProfilerStatisticsChildrenModel(QmlProfilerModelManager *modelManager,
QmlProfilerStatisticsModel *statisticsModel,
QObject *parent = 0);
protected:
virtual void loadData();
};
}
} // namespace QmlProfiler