15#ifndef QGSRUNTIMEPROFILER_H
16#define QGSRUNTIMEPROFILER_H
19#include <QElapsedTimer>
24#include <QAbstractItemModel>
46 Name = Qt::UserRole + 1,
74 QStringList fullParentPath()
const;
79 QVariant data(
int role = Qt::DisplayRole )
const;
89 void addChild( std::unique_ptr< QgsRuntimeProfilerNode > child );
117 void removeChildAt(
int index );
133 void setElapsed(
double time );
140 double elapsed()
const;
146 double totalElapsedTimeForChildren(
const QString &group )
const;
149 std::deque< std::unique_ptr< QgsRuntimeProfilerNode > > mChildren;
151 QElapsedTimer mProfileTime;
195 Q_DECL_DEPRECATED
void beginGroup(
const QString &name )
SIP_DEPRECATED;
208 QStringList childGroups( const QString &parent = QString(), const QString &group = "startup" ) const;
215 void start( const QString &name, const QString &group = "startup" );
220 void end( const QString &group = "startup" );
226 double profileTime( const QString &name, const QString &group = "startup" ) const;
231 void clear( const QString &group = "startup" );
237 double totalTime( const QString &group = "startup" );
242 QSet< QString > groups()
const {
return mGroups; }
250 bool groupIsActive(
const QString &group )
const;
255 static QString translateGroupName(
const QString &group );
259 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
260 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
261 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
262 QModelIndex parent(
const QModelIndex &child )
const override;
263 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
264 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
270 void started(
const QString &group,
const QStringList &path,
const QString &name );
271 void ended(
const QString &group,
const QStringList &path,
const QString &name,
double elapsed );
282 void otherProfilerStarted(
const QString &group,
const QStringList &path,
const QString &name );
283 void otherProfilerEnded(
const QString &group,
const QStringList &path,
const QString &name,
double elapsed );
289 bool mInitialized =
false;
290 void setupConnections();
302 QMap< QString, QStack< QgsRuntimeProfilerNode * > > mCurrentStack;
303 std::unique_ptr< QgsRuntimeProfilerNode > mRootNode;
305 QSet< QString > mGroups;
352 void switchTask(
const QString &name );
Extends QApplication to provide access to QGIS specific resources such as theme paths,...
A node representing an entry in a QgsRuntimeProfiler.
QgsRuntimeProfilerNode(const QgsRuntimeProfilerNode &other)=delete
QgsRuntimeProfilerNode cannot be copied.
QgsRuntimeProfilerNode & operator=(const QgsRuntimeProfilerNode &other)=delete
QgsRuntimeProfilerNode cannot be copied.
Roles
Custom node data roles.
@ Elapsed
Node elapsed time.
@ ParentElapsed
Total elapsed time for node's parent.
QgsRuntimeProfilerNode * parent()
Returns the node's parent node.
int childCount() const
Returns the number of child nodes owned by this node.
~QgsRuntimeProfilerNode()
Provides a method of recording run time profiles of operations, allowing easy recording of their over...
void groupAdded(const QString &group)
Emitted when a new group has started being profiled.
~QgsRuntimeProfiler() override
Scoped object for logging of the runtime for a single operation or group of operations.