2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
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"
|
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:
|
|
|
|
|
|
2018-05-09 09:27:07 +02:00
|
|
|
struct Item {
|
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
|
|
|
|
2018-05-09 09:27:07 +02:00
|
|
|
Item(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
|
|
|
};
|
|
|
|
|
|
2018-03-28 15:40:13 +02:00
|
|
|
MemoryUsageModel(QmlProfilerModelManager *manager, Timeline::TimelineModelAggregator *parent);
|
2014-05-27 16:30:48 +02:00
|
|
|
|
2018-01-11 13:31:58 +01:00
|
|
|
qint64 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;
|
2016-11-08 18:11:36 +01:00
|
|
|
QRgb color(int index) const override;
|
2016-05-24 14:03:39 +02:00
|
|
|
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
|
|
|
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 {
|
2018-11-24 12:14:44 +01:00
|
|
|
RangeStackFrame() = default;
|
2016-04-28 16:13:16 +02:00
|
|
|
RangeStackFrame(int originTypeIndex, qint64 startTime) :
|
|
|
|
|
originTypeIndex(originTypeIndex), startTime(startTime) {}
|
2018-11-24 12:14:44 +01:00
|
|
|
int originTypeIndex = -1;
|
|
|
|
|
qint64 startTime = -1;
|
2016-04-26 13:23:35 +02:00
|
|
|
};
|
|
|
|
|
|
2016-06-03 15:50:32 +02:00
|
|
|
enum EventContinuation {
|
|
|
|
|
ContinueNothing = 0x0,
|
|
|
|
|
ContinueAllocation = 0x1,
|
|
|
|
|
ContinueUsage = 0x2
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-09 09:27:07 +02:00
|
|
|
QVector<Item> 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
|