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-10-27 17:41:22 +01:00
|
|
|
#include "qmlprofilernotesmodel.h"
|
2016-05-02 12:18:57 +02:00
|
|
|
#include "qmlprofilereventtypes.h"
|
2016-05-04 18:54:59 +02:00
|
|
|
#include "qmleventlocation.h"
|
2016-04-28 16:02:54 +02:00
|
|
|
#include "qmlprofilerconstants.h"
|
2016-05-02 12:18:57 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
#include <QHash>
|
2016-09-08 18:26:55 +02:00
|
|
|
#include <QStack>
|
2013-08-08 13:28:08 +02:00
|
|
|
#include <QVector>
|
2016-05-02 12:18:57 +02:00
|
|
|
#include <QObject>
|
2018-03-23 09:28:57 +01:00
|
|
|
#include <QPointer>
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
class QmlProfilerModelManager;
|
2016-04-26 16:38:56 +02:00
|
|
|
class QmlProfilerStatisticsRelativesModel;
|
|
|
|
|
|
|
|
|
|
enum QmlProfilerStatisticsRelation {
|
|
|
|
|
QmlProfilerStatisticsChilden,
|
|
|
|
|
QmlProfilerStatisticsParents
|
|
|
|
|
};
|
2013-08-08 13:28:08 +02:00
|
|
|
|
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 {
|
2018-03-23 09:28:57 +01:00
|
|
|
qint64 duration = 0;
|
|
|
|
|
qint64 durationSelf = 0;
|
|
|
|
|
qint64 durationRecursive = 0;
|
|
|
|
|
qint64 calls = 0;
|
|
|
|
|
qint64 minTime = std::numeric_limits<qint64>::max();
|
|
|
|
|
qint64 maxTime = 0;
|
|
|
|
|
qint64 medianTime = 0;
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
2016-12-28 18:12:49 +01:00
|
|
|
double durationPercent(int typeId) const;
|
|
|
|
|
double durationSelfPercent(int typeId) const;
|
|
|
|
|
|
2018-03-23 09:28:57 +01:00
|
|
|
QmlProfilerStatisticsModel(QmlProfilerModelManager *modelManager);
|
|
|
|
|
~QmlProfilerStatisticsModel() override = default;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2018-03-23 09:51:44 +01:00
|
|
|
void restrictToFeatures(quint64 features);
|
2018-03-23 09:28:57 +01:00
|
|
|
bool isRestrictedToRange() const;
|
2014-03-06 16:12:02 +01:00
|
|
|
|
2014-06-13 16:34:30 +02:00
|
|
|
const QHash<int, QmlEventStats> &getData() const;
|
2016-04-26 11:50:59 +02:00
|
|
|
const QVector<QmlEventType> &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();
|
|
|
|
|
|
2016-04-26 16:38:56 +02:00
|
|
|
void setRelativesModel(QmlProfilerStatisticsRelativesModel *childModel,
|
|
|
|
|
QmlProfilerStatisticsRelation relation);
|
2016-04-28 16:13:16 +02:00
|
|
|
QmlProfilerModelManager *modelManager() const;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void dataAvailable();
|
2014-09-26 18:25:39 +02:00
|
|
|
void notesAvailable(int typeIndex);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-04-26 16:38:56 +02:00
|
|
|
void loadEvent(const QmlEvent &event, const QmlEventType &type);
|
|
|
|
|
void finalize();
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
void dataChanged();
|
2014-09-26 18:25:39 +02:00
|
|
|
void notesChanged(int typeIndex);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2018-03-23 09:28:57 +01:00
|
|
|
QHash<int, QmlEventStats> m_data;
|
|
|
|
|
|
|
|
|
|
QPointer<QmlProfilerStatisticsRelativesModel> m_calleesModel;
|
|
|
|
|
QPointer<QmlProfilerStatisticsRelativesModel> m_callersModel;
|
|
|
|
|
QPointer<QmlProfilerModelManager> m_modelManager;
|
|
|
|
|
|
|
|
|
|
QList<RangeType> m_acceptedTypes;
|
|
|
|
|
QHash<int, QString> m_notes;
|
|
|
|
|
|
|
|
|
|
QStack<QmlEvent> m_callStack;
|
|
|
|
|
QStack<QmlEvent> m_compileStack;
|
|
|
|
|
QHash<int, QVector<qint64>> m_durations;
|
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:
|
2016-04-26 16:38:56 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
struct QmlStatisticsRelativesData {
|
2018-03-23 09:28:57 +01:00
|
|
|
qint64 duration = 0;
|
|
|
|
|
qint64 calls = 0;
|
|
|
|
|
bool isRecursive = false;
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
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,
|
2018-03-23 09:28:57 +01:00
|
|
|
QmlProfilerStatisticsRelation relation);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
int count() const;
|
|
|
|
|
void clear();
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
const QmlStatisticsRelativesMap &getData(int typeId) const;
|
2016-04-26 11:50:59 +02:00
|
|
|
const QVector<QmlEventType> &getTypes() const;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-12-28 18:12:49 +01:00
|
|
|
void loadEvent(RangeType type, const QmlEvent &event, bool isRecursive);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-05-24 15:50:31 +02:00
|
|
|
QmlProfilerStatisticsRelation relation() const;
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
signals:
|
|
|
|
|
void dataAvailable();
|
|
|
|
|
|
|
|
|
|
protected:
|
2018-03-23 09:28:57 +01:00
|
|
|
QHash<int, QmlStatisticsRelativesMap> m_data;
|
|
|
|
|
QPointer<QmlProfilerModelManager> m_modelManager;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-09-08 18:26:55 +02:00
|
|
|
struct Frame {
|
2018-03-23 09:28:57 +01:00
|
|
|
qint64 startTime = 0;
|
|
|
|
|
int typeId = -1;
|
2016-09-08 18:26:55 +02:00
|
|
|
};
|
|
|
|
|
QStack<Frame> m_callStack;
|
|
|
|
|
QStack<Frame> m_compileStack;
|
2016-04-26 16:38:56 +02:00
|
|
|
const QmlProfilerStatisticsRelation m_relation;
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
2016-04-26 16:38:56 +02:00
|
|
|
} // namespace QmlProfiler
|