aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2018-03-23 15:24:53 +0100
committerUlf Hermann <[email protected]>2018-04-17 09:09:32 +0000
commite0cab799657b85f821c2d17550c7eafea910cc8e (patch)
tree8d9bc35c237fedf82758baf53bf00960b412693c /src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h
parent858a178294f4a05b73b4f17085d58f89fd3d644a (diff)
QmlProfiler: Clean up type selection in statistics model
The statistics have one extra valid event type: "Main Program". This should not be mapped to typeId -1, as -1 is the invalid typeId. Map it instead to std::numeric_limits<int>::max() and remove all the hacks around it. Additionally, optimize the selection algorithm for the statistics main view: We don't need to iterate all types to select one. We can rather use the fact that the row numbers in the source model match the type indices (except for the two special ones). Change-Id: I7c4dc4f84fd167f9a21c418466ad2bfce56e441f Reviewed-by: Tobias Hunger <[email protected]>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h
index c25cca0baf4..6c8785b6642 100644
--- a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h
+++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.h
@@ -145,6 +145,9 @@ public:
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+ static const int s_mainEntryTypeId = std::numeric_limits<int>::max();
+ static const int s_invalidTypeId = -1;
+
private:
void loadEvent(const QmlEvent &event, const QmlEventType &type);
void finalize();
@@ -178,7 +181,8 @@ class QmlProfilerStatisticsRelativesModel : public QAbstractTableModel
public:
struct QmlStatisticsRelativesData {
- QmlStatisticsRelativesData(qint64 duration = 0, qint64 calls = 0, int typeIndex = -1,
+ QmlStatisticsRelativesData(qint64 duration = 0, qint64 calls = 0,
+ int typeIndex = QmlProfilerStatisticsModel::s_invalidTypeId,
bool isRecursive = false)
: duration(duration), calls(calls), typeIndex(typeIndex), isRecursive(isRecursive) {}
qint64 duration;
@@ -207,10 +211,11 @@ private:
QHash<int, QVector<QmlStatisticsRelativesData>> m_data;
QPointer<QmlProfilerModelManager> m_modelManager;
- int m_relativeTypeIndex = std::numeric_limits<int>::max();
+ int m_relativeTypeIndex = QmlProfilerStatisticsModel::s_invalidTypeId;
struct Frame {
- Frame(qint64 startTime = 0, int typeId = -1) : startTime(startTime), typeId(typeId) {}
+ Frame(qint64 startTime = 0, int typeId = QmlProfilerStatisticsModel::s_invalidTypeId)
+ : startTime(startTime), typeId(typeId) {}
qint64 startTime;
int typeId;
};