pyqt_reactive.core.performance_monitor

Performance monitoring utilities for pyqt-reactor.

Provides decorators and context managers for timing operations and logging performance metrics.

Functions

disable_performance_logging()

Disable performance logging.

enable_performance_logging()

Enable performance logging.

get_monitor(operation_name)

Get or create a global monitor for an operation.

is_performance_logging_enabled()

Check if performance logging is enabled.

report_all_monitors()

Report statistics for all global monitors.

reset_all_monitors()

Reset all global monitors.

timed([operation_name, threshold_ms])

Decorator for timing function calls.

timer(operation_name[, threshold_ms, log_args])

Context manager for timing operations.

Classes

PerformanceMonitor(operation_name)

Accumulates timing statistics for repeated operations.

pyqt_reactive.core.performance_monitor.timer(operation_name: str, threshold_ms: float = 0.0, log_args: bool = False, **kwargs)[source]

Context manager for timing operations.

Parameters:
  • operation_name – Name of the operation being timed

  • threshold_ms – Only log if operation takes longer than this (in milliseconds)

  • log_args – Whether to log kwargs in the message

  • **kwargs – Additional context to include in log message

Example

with timer(“Loading config”, threshold_ms=10.0, config_type=”GlobalPipelineConfig”):

config = load_config()

pyqt_reactive.core.performance_monitor.timed(operation_name: str | None = None, threshold_ms: float = 0.0)[source]

Decorator for timing function calls.

Parameters:
  • operation_name – Name for the operation (defaults to function name)

  • threshold_ms – Only log if operation takes longer than this (in milliseconds)

Example

@timed(“Config loading”, threshold_ms=10.0) def load_config():

class pyqt_reactive.core.performance_monitor.PerformanceMonitor(operation_name: str)[source]

Accumulates timing statistics for repeated operations.

Example

monitor = PerformanceMonitor(“Placeholder resolution”)

for field in fields:
with monitor.measure():

resolve_placeholder(field)

monitor.report() # Logs summary statistics

__init__(operation_name: str)[source]
measure()[source]

Measure a single operation.

report(log_individual: bool = False)[source]

Log summary statistics.

Parameters:

log_individual – Whether to log each individual timing

reset()[source]

Clear all timings.

pyqt_reactive.core.performance_monitor.get_monitor(operation_name: str) PerformanceMonitor[source]

Get or create a global monitor for an operation.

Example

monitor = get_monitor(“Placeholder resolution”) with monitor.measure():

resolve_placeholder(field)

pyqt_reactive.core.performance_monitor.report_all_monitors()[source]

Report statistics for all global monitors.

pyqt_reactive.core.performance_monitor.reset_all_monitors()[source]

Reset all global monitors.

pyqt_reactive.core.performance_monitor.enable_performance_logging()[source]

Enable performance logging.

pyqt_reactive.core.performance_monitor.disable_performance_logging()[source]

Disable performance logging.

pyqt_reactive.core.performance_monitor.is_performance_logging_enabled() bool[source]

Check if performance logging is enabled.