QGIS API Documentation  3.21.0-Master (5b68dc587e)
Public Member Functions | List of all members
QgsScopedRuntimeProfile Class Reference

Scoped object for logging of the runtime for a single operation or group of operations. More...

#include <qgsruntimeprofiler.h>

Public Member Functions

 QgsScopedRuntimeProfile (const QString &name, const QString &group="startup")
 Constructor for QgsScopedRuntimeProfile. More...
 
 ~QgsScopedRuntimeProfile ()
 Records the final runtime of the operation in the profiler instance. More...
 
void switchTask (const QString &name)
 Switches the current task managed by the scoped profile to a new task with the given name. More...
 

Detailed Description

Scoped object for logging of the runtime for a single operation or group of operations.

This class automatically takes care of registering an operation in the QgsApplication::profiler() registry upon construction, and recording of the elapsed runtime upon destruction.

Python scripts should not use QgsScopedRuntimeProfile directly. Instead, use QgsRuntimeProfiler.profile()

with QgsRuntimeProfiler.profile('My operation'):
# do something
Since
QGIS 3.14

Definition at line 327 of file qgsruntimeprofiler.h.

Constructor & Destructor Documentation

◆ QgsScopedRuntimeProfile()

QgsScopedRuntimeProfile::QgsScopedRuntimeProfile ( const QString &  name,
const QString &  group = "startup" 
)

Constructor for QgsScopedRuntimeProfile.

Automatically registers the operation in the QgsApplication::profiler() instance and starts recording the run time of the operation.

Definition at line 583 of file qgsruntimeprofiler.cpp.

◆ ~QgsScopedRuntimeProfile()

QgsScopedRuntimeProfile::~QgsScopedRuntimeProfile ( )

Records the final runtime of the operation in the profiler instance.

Definition at line 589 of file qgsruntimeprofiler.cpp.

Member Function Documentation

◆ switchTask()

void QgsScopedRuntimeProfile::switchTask ( const QString &  name)

Switches the current task managed by the scoped profile to a new task with the given name.

The current task will be finalised before switching.

This is useful for reusing an existing scoped runtime profiler with multi-step processes.

Since
QGIS 3.14

Definition at line 594 of file qgsruntimeprofiler.cpp.


The documentation for this class was generated from the following files: