Class: QgsRuntimeProfiler

Provides a method of recording run time profiles of operations, allowing easy recording of their overall run time.

QgsRuntimeProfiler is not usually instantied manually, but rather accessed through QgsApplication.profiler().

This class is thread-safe only if accessed through QgsApplication.profiler(). If accessed in this way, operations can be profiled from non-main threads.

Class Hierarchy

Inheritance diagram of qgis.core.QgsRuntimeProfiler

Base classes

QAbstractItemModel

QObject

Methods

asText

Returns the model as a multi-line text string.

beginGroup

Begin the group for the profiler.

childGroups

Returns a list of all child groups with the specified parent.

clear

clear Clear all profile data.

end

End the current profile event.

endGroup

End the current active group.

groupAdded

Emitted when a new group has started being profiled.

groupIsActive

Returns True if the specified group is currently being logged, i.e. it has a entry which has started and not yet stopped.

groups

Returns the set of known groups.

profileTime

Returns the profile time for the specified name.

record

Manually adds a profile event with the given name and total time (in seconds).

start

Start a profile event with the given name.

totalTime

The current total time collected in the profiler.

Static Methods

translateGroupName

Returns the translated name of a standard profile group.

class qgis.core.QgsRuntimeProfiler[source]

Bases: QAbstractItemModel

__init__()

Constructor to create a new runtime profiler.

Warning

QgsRuntimeProfiler is not usually instantied manually, but rather accessed through QgsApplication.profiler().

asText(self, group: str | None = '') str[source]

Returns the model as a multi-line text string.

Parameters:

group (Optional[str] = '') – A group name to filter the model against.

Added in version 3.34.

Return type:

str

beginGroup(self, name: str | None)[source]

Begin the group for the profiler. Groups will append {GroupName}/ to the front of the profile tag set using start.

Parameters:

name (Optional[str]) – The name of the group.

Deprecated since version 3.40: Use start() instead.

childGroups(self, parent: str | None = '', group: str | None = '') List[str][source]

Returns a list of all child groups with the specified parent.

Added in version 3.14.

Parameters:
  • parent (Optional[str] = '')

  • group (Optional[str] = '')

Return type:

List[str]

clear(self, group: str | None = '')[source]

clear Clear all profile data.

Parameters:

group (Optional[str] = '')

end(self, group: str | None = '')[source]

End the current profile event.

Parameters:

group (Optional[str] = '')

endGroup(self)[source]

End the current active group.

Deprecated since version 3.40: Use end() instead.

groupAdded(self, group: str | None)[source]

Emitted when a new group has started being profiled.

Parameters:

group (Optional[str])

groupIsActive(self, group: str | None) bool[source]

Returns True if the specified group is currently being logged, i.e. it has a entry which has started and not yet stopped.

Added in version 3.14.

Parameters:

group (Optional[str])

Return type:

bool

groups(self) Set[str]

Returns the set of known groups.

Return type:

Set[str]

profile

alias of ScopedRuntimeProfileContextManager

profileTime(self, name: str | None, group: str | None = '') float[source]

Returns the profile time for the specified name.

Added in version 3.14.

Parameters:
  • name (Optional[str])

  • group (Optional[str] = '')

Return type:

float

record(self, name: str | None, time: float, group: str | None = '', id: str | None = '')[source]

Manually adds a profile event with the given name and total time (in seconds).

The optional id argument can be used to provider a unique ID to disambiguate nodes with the same name.

Added in version 3.34.

Parameters:
  • name (Optional[str])

  • time (float)

  • group (Optional[str] = '')

  • id (Optional[str] = '')

start(self, name: str | None, group: str | None = '', id: str | None = '')[source]

Start a profile event with the given name. The name of the profile event. Will have the name of the active group appended after ending.

Since QGIS 3.34, the optional id argument can be used to provide a unique ID to disambiguate nodes with the same name.

Parameters:
  • name (Optional[str])

  • group (Optional[str] = '')

  • id (Optional[str] = '')

totalTime(self, group: str | None = '') float[source]

The current total time collected in the profiler.

Return type:

float

Returns:

The current total time collected in the profiler.

Parameters:

group (Optional[str] = '')

static translateGroupName(group: str | None) str[source]

Returns the translated name of a standard profile group.

Parameters:

group (Optional[str])

Return type:

str