15#ifndef QGSRUNTIMEPROFILER_H
16#define QGSRUNTIMEPROFILER_H
24#include <QAbstractItemModel>
25#include <QElapsedTimer>
54 Name = Qt::UserRole + 1,
86 QStringList fullParentPath()
const;
91 QVariant data(
int role = Qt::DisplayRole )
const;
101 void addChild( std::unique_ptr< QgsRuntimeProfilerNode > child );
114 QgsRuntimeProfilerNode *child(
const QString &group,
const QString &name,
const QString &
id = QString() );
129 void removeChildAt(
int index );
145 void setElapsed(
double time );
152 double elapsed()
const;
158 double totalElapsedTimeForChildren(
const QString &group )
const;
161 std::deque< std::unique_ptr< QgsRuntimeProfilerNode > > mChildren;
163 QElapsedTimer mProfileTime;
219 QStringList
childGroups( const QString &
parent = QString(), const QString &group =
"startup" ) const;
229 void start( const QString &name, const QString &group =
"startup", const QString &
id = QString() );
234 void end( const QString &group =
"startup" );
244 void record( const QString &name,
double time, const QString &group =
"startup", const QString &
id = QString() );
250 double profileTime( const QString &name, const QString &group =
"startup" ) const;
255 void clear( const QString &group =
"startup" );
261 double totalTime( const QString &group =
"startup" );
266 QSet< QString >
groups()
const {
return mGroups; }
274 bool groupIsActive(
const QString &group )
const;
279 static QString translateGroupName(
const QString &group );
283 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
284 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
285 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
286 QModelIndex parent(
const QModelIndex &child )
const override;
287 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
288 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
295 QString asText(
const QString &group = QString() );
301 void started(
const QString &group,
const QStringList &path,
const QString &name,
const QString &
id );
302 void ended(
const QString &group,
const QStringList &path,
const QString &name,
const QString &
id,
double elapsed );
313 void otherProfilerStarted(
const QString &group,
const QStringList &path,
const QString &name,
const QString &
id );
314 void otherProfilerEnded(
const QString &group,
const QStringList &path,
const QString &name,
const QString &
id,
double elapsed );
319 bool mInitialized =
false;
320 void setupConnections();
326 void extractModelAsText( QStringList &lines,
const QString &group,
const QModelIndex &
parent = QModelIndex(),
int level = 0 );
333 QMap< QString, QStack< QgsRuntimeProfilerNode * > > mCurrentStack;
334 std::unique_ptr< QgsRuntimeProfilerNode > mRootNode;
336 QSet< QString > mGroups;
370 QgsScopedRuntimeProfile(
const QString &name,
const QString &group =
"startup",
const QString &
id = QString() );
A node representing an entry in a QgsRuntimeProfiler.
QgsRuntimeProfilerNode(const QgsRuntimeProfilerNode &other)=delete
QgsRuntimeProfilerNode & operator=(const QgsRuntimeProfilerNode &other)=delete
CustomRole
Custom node data roles.
QgsRuntimeProfilerNode(const QString &group, const QString &name, const QString &id=QString())
Constructor for QgsRuntimeProfilerNode, with the specified group and name.
QgsRuntimeProfilerNode * parent()
Returns the node's parent node.
int childCount() const
Returns the number of child nodes owned by this node.
~QgsRuntimeProfilerNode()
void groupAdded(const QString &group)
Emitted when a new group has started being profiled.
QModelIndex parent(const QModelIndex &child) const override
double profileTime(const QString &name, const QString &group="startup") const
Returns the profile time for the specified name.
QgsRuntimeProfiler()
Constructor to create a new runtime profiler.
void start(const QString &name, const QString &group="startup", const QString &id=QString())
Start a profile event with the given name.
QStringList childGroups(const QString &parent=QString(), const QString &group="startup") const
Returns a list of all child groups with the specified parent.
QSet< QString > groups() const
Returns the set of known groups.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void end(const QString &group="startup")
End the current profile event.
friend class QgsApplication
double totalTime(const QString &group="startup")
The current total time collected in the profiler.
void clear(const QString &group="startup")
clear Clear all profile data.
Q_DECL_DEPRECATED void beginGroup(const QString &name)
Begin the group for the profiler.
~QgsRuntimeProfiler() override
Q_DECL_DEPRECATED void endGroup()
End the current active group.
void record(const QString &name, double time, const QString &group="startup", const QString &id=QString())
Manually adds a profile event with the given name and total time (in seconds).
void switchTask(const QString &name)
Switches the current task managed by the scoped profile to a new task with the given name.
QgsScopedRuntimeProfile(const QString &name, const QString &group="startup", const QString &id=QString())
Constructor for QgsScopedRuntimeProfile.
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)