2014-05-27 16:30:48 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-14 11:03:04 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-05-27 16:30:48 +02:00
|
|
|
**
|
2016-01-14 11:03:04 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-05-27 16:30:48 +02:00
|
|
|
**
|
2016-01-14 11:03:04 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-05-27 16:30:48 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-14 11:03:04 +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.
|
2014-05-27 16:30:48 +02:00
|
|
|
**
|
2016-01-14 11:03:04 +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.
|
2014-05-27 16:30:48 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2014-05-27 16:30:48 +02:00
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
#include "qmlprofilertimelinemodel.h"
|
|
|
|
|
#include "qmlprofilerdatamodel.h"
|
2014-05-27 16:30:48 +02:00
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QColor>
|
2016-04-26 13:23:35 +02:00
|
|
|
#include <QStack>
|
2014-05-27 16:30:48 +02:00
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
namespace QmlProfiler {
|
2014-05-27 16:30:48 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
class MemoryUsageModel : public QmlProfilerTimelineModel
|
2014-05-27 16:30:48 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
struct MemoryAllocationItem {
|
2014-05-27 16:30:48 +02:00
|
|
|
qint64 size;
|
2014-07-11 11:01:47 +02:00
|
|
|
qint64 allocated;
|
|
|
|
|
qint64 deallocated;
|
|
|
|
|
int allocations;
|
|
|
|
|
int deallocations;
|
2016-05-26 09:27:59 +02:00
|
|
|
int typeId;
|
2014-07-11 11:01:47 +02:00
|
|
|
|
2016-05-26 09:27:59 +02:00
|
|
|
MemoryAllocationItem(int typeId = -1, qint64 baseAmount = 0);
|
2014-07-11 11:01:47 +02:00
|
|
|
void update(qint64 amount);
|
2014-05-27 16:30:48 +02:00
|
|
|
};
|
|
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
MemoryUsageModel(QmlProfilerModelManager *manager, QObject *parent = 0);
|
2014-05-27 16:30:48 +02:00
|
|
|
|
2016-05-24 14:03:39 +02:00
|
|
|
int rowMaxValue(int rowNumber) const override;
|
2014-05-27 16:30:48 +02:00
|
|
|
|
2016-05-24 14:03:39 +02:00
|
|
|
int expandedRow(int index) const override;
|
|
|
|
|
int collapsedRow(int index) const override;
|
|
|
|
|
int typeId(int index) const override;
|
|
|
|
|
QColor color(int index) const override;
|
|
|
|
|
float relativeHeight(int index) const override;
|
2014-05-27 16:30:48 +02:00
|
|
|
|
2016-05-24 14:03:39 +02:00
|
|
|
QVariantMap location(int index) const override;
|
2014-06-24 11:53:47 +02:00
|
|
|
|
2016-05-24 14:03:39 +02:00
|
|
|
QVariantList labels() const override;
|
|
|
|
|
QVariantMap details(int index) const override;
|
2014-05-27 16:30:48 +02:00
|
|
|
|
2016-04-26 13:23:35 +02:00
|
|
|
bool accepted(const QmlEventType &type) const override;
|
|
|
|
|
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
|
|
|
|
|
void finalize() override;
|
|
|
|
|
void clear() override;
|
2016-09-09 10:34:39 +02:00
|
|
|
bool handlesTypeId(int typeId) const override;
|
2014-05-27 16:30:48 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-04-26 13:23:35 +02:00
|
|
|
struct RangeStackFrame {
|
2016-04-28 16:13:16 +02:00
|
|
|
RangeStackFrame() : originTypeIndex(-1), startTime(-1) {}
|
|
|
|
|
RangeStackFrame(int originTypeIndex, qint64 startTime) :
|
|
|
|
|
originTypeIndex(originTypeIndex), startTime(startTime) {}
|
2016-04-26 13:23:35 +02:00
|
|
|
int originTypeIndex;
|
|
|
|
|
qint64 startTime;
|
|
|
|
|
};
|
|
|
|
|
|
2016-06-03 15:50:32 +02:00
|
|
|
enum EventContinuation {
|
|
|
|
|
ContinueNothing = 0x0,
|
|
|
|
|
ContinueAllocation = 0x1,
|
|
|
|
|
ContinueUsage = 0x2
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
QVector<MemoryAllocationItem> m_data;
|
2016-04-26 13:23:35 +02:00
|
|
|
QStack<RangeStackFrame> m_rangeStack;
|
|
|
|
|
qint64 m_maxSize = 1;
|
|
|
|
|
qint64 m_currentSize = 0;
|
|
|
|
|
qint64 m_currentUsage = 0;
|
|
|
|
|
int m_currentUsageIndex = -1;
|
|
|
|
|
int m_currentJSHeapIndex = -1;
|
2016-06-03 15:50:32 +02:00
|
|
|
|
|
|
|
|
int m_continuation = ContinueNothing;
|
2014-05-27 16:30:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2016-04-26 10:21:00 +02:00
|
|
|
} // namespace QmlProfiler
|