QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
StateMachineProfiler Class Reference

#include <StateMachineProfiler.h>

+ Inheritance diagram for StateMachineProfiler:
+ Collaboration diagram for StateMachineProfiler:

Classes

struct  StateProfile
 

Public Member Functions

 StateMachineProfiler (QGCStateMachine *machine)
 
 ~StateMachineProfiler () override=default
 
void setEnabled (bool enabled)
 Enable or disable profiling.
 
bool isEnabled () const
 
void reset ()
 Reset all profiling data.
 
StateProfile profile (const QString &stateName) const
 Get profile data for a specific state.
 
QHash< QString, StateProfileallProfiles () const
 Get profile data for all states.
 
qint64 totalRuntimeMs () const
 Get total machine runtime.
 
int transitionCount () const
 Get the number of state transitions.
 
QString summary () const
 Get a human-readable summary.
 
QJsonObject toJson () const
 Export profile data as JSON.
 
void logProfile () const
 Log the profile to debug output.
 

Detailed Description

Performance profiler for state machines.

Tracks time spent in each state and provides profiling data.

Usage:

QGCStateMachine machine("MyMachine", nullptr);
StateMachineProfiler profiler(&machine);
profiler.setEnabled(true);
// ... run state machine ...
qDebug() << profiler.summary();
qDebug() << profiler.toJson();
QGroundControl specific state machine with enhanced error handling.

Definition at line 27 of file StateMachineProfiler.h.

Constructor & Destructor Documentation

◆ StateMachineProfiler()

StateMachineProfiler::StateMachineProfiler ( QGCStateMachine machine)
explicit

Definition at line 8 of file StateMachineProfiler.cc.

◆ ~StateMachineProfiler()

StateMachineProfiler::~StateMachineProfiler ( )
overridedefault

Member Function Documentation

◆ allProfiles()

QHash< QString, StateProfile > StateMachineProfiler::allProfiles ( ) const
inline

Get profile data for all states.

Definition at line 59 of file StateMachineProfiler.h.

◆ isEnabled()

bool StateMachineProfiler::isEnabled ( ) const
inline

Definition at line 50 of file StateMachineProfiler.h.

◆ logProfile()

void StateMachineProfiler::logProfile ( ) const

Log the profile to debug output.

Definition at line 116 of file StateMachineProfiler.cc.

References summary().

◆ profile()

StateMachineProfiler::StateProfile StateMachineProfiler::profile ( const QString &  stateName) const

Get profile data for a specific state.

Definition at line 50 of file StateMachineProfiler.cc.

◆ reset()

void StateMachineProfiler::reset ( )

Reset all profiling data.

Definition at line 42 of file StateMachineProfiler.cc.

◆ setEnabled()

void StateMachineProfiler::setEnabled ( bool  enabled)

Enable or disable profiling.

Definition at line 16 of file StateMachineProfiler.cc.

◆ summary()

QString StateMachineProfiler::summary ( ) const

Get a human-readable summary.

Definition at line 55 of file StateMachineProfiler.cc.

Referenced by logProfile().

◆ toJson()

QJsonObject StateMachineProfiler::toJson ( ) const

Export profile data as JSON.

Definition at line 92 of file StateMachineProfiler.cc.

◆ totalRuntimeMs()

qint64 StateMachineProfiler::totalRuntimeMs ( ) const
inline

Get total machine runtime.

Definition at line 62 of file StateMachineProfiler.h.

◆ transitionCount()

int StateMachineProfiler::transitionCount ( ) const
inline

Get the number of state transitions.

Definition at line 65 of file StateMachineProfiler.h.


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