sec_interp.core.performance_metrics module
- class sec_interp.core.performance_metrics.MetricsCollector[source]
Bases:
objectCollects and aggregates performance metrics.
- timings
Dictionary mapping operation names to durations.
- counts
Dictionary mapping metric names to integer counts.
- metadata
Dictionary of additional context and metadata.
- add_metadata(key: str, value: Any) None[source]
Add metadata to the metrics collection.
- Parameters:
key – Metadata key
value – Metadata value
- get_summary() dict[str, Any][source]
Get summary of collected metrics.
- Returns:
A dictionary with all collected metrics including total duration.
- class sec_interp.core.performance_metrics.PerformanceMonitor(log_file='performance.log')[source]
Bases:
objectPerformance monitoring using only Python standard library.
Tracks duration and memory usage of specific operations.
- __init__(log_file='performance.log')[source]
Initialize monitor and setup logging.
- Parameters:
log_file – Path to the performance log file.
- class sec_interp.core.performance_metrics.PerformanceTimer(operation_name: str, collector: MetricsCollector | None = None, logger_func: Any | None = None)[source]
Bases:
objectContext manager for timing specific operations.
- __exit__(exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any | None) None[source]
Stop the timer and record/log validity.
- Parameters:
exc_type – Exception type if raised
exc_val – Exception value if raised
exc_tb – Exception traceback if raised
- __init__(operation_name: str, collector: MetricsCollector | None = None, logger_func: Any | None = None)[source]
Initialize timer.
- Parameters:
operation_name – Name of operation to measure
collector – Optional metrics collector to record into
logger_func – Optional logger function for immediate logging