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. |
|
Enable performance logging. |
|
|
Get or create a global monitor for an operation. |
Check if performance logging is enabled. |
|
Report statistics for all global monitors. |
|
Reset all global monitors. |
|
|
Decorator for timing function calls. |
|
Context manager for timing operations. |
Classes
|
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
- 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.enable_performance_logging()[source]
Enable performance logging.