2013-08-08 13:28:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-08-08 13:28:08 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-08-08 13:28:08 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-08-08 13:28:08 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2014-02-18 17:32:20 +01:00
|
|
|
#include "qmlprofilerdatamodel.h"
|
2014-10-27 17:41:22 +01:00
|
|
|
#include "qmlprofilernotesmodel.h"
|
2013-08-08 13:28:08 +02:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <qmldebug/qmlprofilereventtypes.h>
|
|
|
|
|
#include <qmldebug/qmlprofilereventlocation.h>
|
|
|
|
|
#include <QHash>
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
class QmlProfilerModelManager;
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
class QmlProfilerStatisticsModel : public QObject
|
2013-08-08 13:28:08 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
struct QmlEventStats {
|
2015-12-03 12:33:00 +01:00
|
|
|
QmlEventStats() : duration(0), durationSelf(0), calls(0),
|
|
|
|
|
minTime(std::numeric_limits<qint64>::max()), maxTime(0), timePerCall(0),
|
|
|
|
|
percentOfTime(0), percentSelf(0), medianTime(0), isBindingLoop(false) {}
|
2013-08-08 13:28:08 +02:00
|
|
|
qint64 duration;
|
2015-12-03 12:33:00 +01:00
|
|
|
qint64 durationSelf;
|
2013-08-08 13:28:08 +02:00
|
|
|
qint64 calls;
|
|
|
|
|
qint64 minTime;
|
|
|
|
|
qint64 maxTime;
|
|
|
|
|
qint64 timePerCall;
|
|
|
|
|
double percentOfTime;
|
2015-12-03 12:33:00 +01:00
|
|
|
double percentSelf;
|
2013-08-08 13:28:08 +02:00
|
|
|
qint64 medianTime;
|
|
|
|
|
|
|
|
|
|
bool isBindingLoop;
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsModel(QmlProfilerModelManager *modelManager, QObject *parent = 0);
|
|
|
|
|
~QmlProfilerStatisticsModel();
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2014-06-03 16:57:32 +02:00
|
|
|
void setEventTypeAccepted(QmlDebug::RangeType type, bool accepted);
|
|
|
|
|
bool eventTypeAccepted(QmlDebug::RangeType) const;
|
2014-03-06 16:12:02 +01:00
|
|
|
|
2014-06-13 16:34:30 +02:00
|
|
|
const QHash<int, QmlEventStats> &getData() const;
|
|
|
|
|
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const;
|
2014-09-26 18:25:39 +02:00
|
|
|
const QHash<int, QString> &getNotes() const;
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
int count() const;
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
void limitToRange(qint64 rangeStart, qint64 rangeEnd);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void dataAvailable();
|
2014-09-26 18:25:39 +02:00
|
|
|
void notesAvailable(int typeIndex);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void loadData(qint64 rangeStart = -1, qint64 rangeEnd = -1);
|
2014-06-13 16:34:30 +02:00
|
|
|
const QSet<int> &eventsInBindingLoop() const;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void dataChanged();
|
2014-09-26 18:25:39 +02:00
|
|
|
void notesChanged(int typeIndex);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
private:
|
2015-12-04 15:41:20 +01:00
|
|
|
class QmlProfilerStatisticsModelPrivate;
|
|
|
|
|
QmlProfilerStatisticsModelPrivate *d;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
friend class QmlProfilerStatisticsParentsModel;
|
|
|
|
|
friend class QmlProfilerStatisticsChildrenModel;
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
class QmlProfilerStatisticsRelativesModel : public QObject
|
2013-08-08 13:28:08 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2015-12-04 15:41:20 +01:00
|
|
|
struct QmlStatisticsRelativesData {
|
2013-08-08 13:28:08 +02:00
|
|
|
qint64 duration;
|
|
|
|
|
qint64 calls;
|
|
|
|
|
bool isBindingLoop;
|
|
|
|
|
};
|
2015-12-04 15:41:20 +01:00
|
|
|
typedef QHash <int, QmlStatisticsRelativesData> QmlStatisticsRelativesMap;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsRelativesModel(QmlProfilerModelManager *modelManager,
|
|
|
|
|
QmlProfilerStatisticsModel *statisticsModel,
|
2013-08-08 13:28:08 +02:00
|
|
|
QObject *parent = 0);
|
|
|
|
|
|
|
|
|
|
int count() const;
|
|
|
|
|
void clear();
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
const QmlStatisticsRelativesMap &getData(int typeId) const;
|
2014-09-26 18:25:39 +02:00
|
|
|
QVariantList getNotes(int typeId) const;
|
2014-06-13 16:34:30 +02:00
|
|
|
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void loadData() = 0;
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void dataAvailable();
|
|
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
|
void dataChanged();
|
|
|
|
|
|
|
|
|
|
protected:
|
2015-12-04 15:41:20 +01:00
|
|
|
QHash <int, QmlStatisticsRelativesMap> m_data;
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerModelManager *m_modelManager;
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsModel *m_statisticsModel;
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
class QmlProfilerStatisticsParentsModel : public QmlProfilerStatisticsRelativesModel
|
2013-08-08 13:28:08 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsParentsModel(QmlProfilerModelManager *modelManager,
|
|
|
|
|
QmlProfilerStatisticsModel *statisticsModel,
|
2013-08-08 13:28:08 +02:00
|
|
|
QObject *parent = 0);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void loadData();
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
class QmlProfilerStatisticsChildrenModel : public QmlProfilerStatisticsRelativesModel
|
2013-08-08 13:28:08 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsChildrenModel(QmlProfilerModelManager *modelManager,
|
|
|
|
|
QmlProfilerStatisticsModel *statisticsModel,
|
2013-08-08 13:28:08 +02:00
|
|
|
QObject *parent = 0);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void loadData();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|