Utilities¶
Utility modules for performance analysis, logging, and metrics collection.
Performance Analysis¶
log_pipeline_performance_analysis
¶
log_pipeline_performance_analysis(pipeline)
Log comprehensive performance analysis for an AsyncTaskPipeline.
Analyzes pipeline performance and logs detailed metrics including overall efficiency, per-stage breakdowns, and individual item timing analysis. This function is useful for identifying bottlenecks and optimizing pipeline performance.
PARAMETER | DESCRIPTION |
---|---|
pipeline
|
The pipeline instance to analyze. Must have timing enabled and have processed at least one item.
TYPE:
|
Notes
This function logs analysis results using the pipeline's logger. If timing is disabled on the pipeline, only a warning message is logged.
Examples:
>>> pipeline = AsyncTaskPipeline(enable_timing=True)
>>> # ... process some data ...
>>> log_pipeline_performance_analysis(pipeline)
Source code in src/async_task_pipeline/utils/analysis.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
Metrics¶
DetailedTiming
¶
Bases: BaseModel
Detailed timing information for a pipeline stage.
Captures precise timing measurements for different phases of item processing within a pipeline stage, enabling detailed performance analysis and bottleneck identification.
PARAMETER | DESCRIPTION |
---|---|
queue_enter_time
|
Timestamp when the item entered the stage's input queue.
TYPE:
|
processing_start_time
|
Timestamp when the stage began processing the item.
TYPE:
|
processing_end_time
|
Timestamp when the stage finished processing the item.
TYPE:
|
queue_exit_time
|
Timestamp when the processed item was placed in the output queue.
TYPE:
|
queue_wait_time
property
¶
queue_wait_time
Time spent waiting in input queue.
RETURNS | DESCRIPTION |
---|---|
float
|
Duration in seconds between queue entry and processing start. |
computation_time
property
¶
computation_time
Time spent in actual computation.
RETURNS | DESCRIPTION |
---|---|
float
|
Duration in seconds of the actual processing function execution. |
transmission_time
property
¶
transmission_time
Time spent in transmission to next stage.
RETURNS | DESCRIPTION |
---|---|
float
|
Duration in seconds between processing completion and output queue placement. |
Logging¶
logging
¶
Logging utilities for the async task pipeline framework.
This module provides a centralized logger instance used throughout the pipeline framework for consistent logging behavior.
logger
module-attribute
¶
logger = getLogger('async_task_pipeline')
Logger instance for the async task pipeline framework.
This logger is used throughout the framework for consistent logging. Configure it at the application level to control log output format, level, and destinations.
Examples:
>>> import logging
>>> from async_task_pipeline.utils import logger
>>>
>>> # Configure logging level
>>> logger.setLevel(logging.INFO)
>>>
>>> # Add a handler
>>> handler = logging.StreamHandler()
>>> logger.addHandler(handler)