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"
|
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>
|
|
|
|
|
#include <QVector>
|
2016-05-02 12:18:57 +02:00
|
|
|
#include <QObject>
|
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 {
|
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
|
|
|
|
2016-04-28 16:13:16 +02:00
|
|
|
void restrictToFeatures(qint64 features);
|
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
|
|
|
|
|
|
|
|
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
|
|
|
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 {
|
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,
|
2016-04-26 16:38:56 +02:00
|
|
|
QmlProfilerStatisticsRelation relation,
|
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;
|
2016-04-26 11:50:59 +02:00
|
|
|
const QVector<QmlEventType> &getTypes() const;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-04-26 16:38:56 +02:00
|
|
|
void loadEvent(const QmlEvent &event);
|
|
|
|
|
void finalize(const QSet<int> &eventsInBindingLoop);
|
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:
|
2015-12-04 15:41:20 +01:00
|
|
|
QHash <int, QmlStatisticsRelativesMap> m_data;
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerModelManager *m_modelManager;
|
|
|
|
|
|
2016-04-26 16:38:56 +02:00
|
|
|
// for level computation
|
2016-04-28 16:13:16 +02:00
|
|
|
QHash<int, qint64> m_startTimesPerLevel;
|
2016-04-26 16:38:56 +02:00
|
|
|
int m_level = Constants::QML_MIN_LEVEL;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-04-26 16:38:56 +02:00
|
|
|
// compute parent-child relationship and call count
|
2016-04-28 16:13:16 +02:00
|
|
|
QHash<int, int> m_typesPerLevel;
|
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
|