tracking
Tracking receiver implementation for the coding experiments library.
This module provides a receiver implementation that collects detailed statistics about message reception, including success rates, processing times, and compression metrics. It’s designed for experimental analysis and performance evaluation.
- class codinglab.receivers.tracking.TransmissionStats(total_messages=0, successful_messages=0, decoded_messages=0, failed_messages=0, total_source_symbols=0, total_channel_symbols=0, decode_errors=0, validation_errors=0, total_processing_time=0.0, avg_message_time=0.0)[source]
Bases:
objectStatistics collected during message transmission and reception.
This class tracks various metrics about the transmission process, including message counts, symbol counts, error rates, and timing information. It also provides computed properties for common performance indicators.
- Parameters:
- property success_rate: float
Calculate the success rate of message transmission.
- Returns:
Ratio of successful messages to total messages, or 0.0 if no messages have been processed
- property compression_ratio: float
Calculate the compression ratio achieved by encoding.
- Returns:
Ratio of source symbols to channel symbols, or 0.0 if no channel symbols have been processed
Note
Values greater than 1.0 indicate compression (fewer channel symbols than source symbols), while values less than 1.0 indicate expansion.
- property average_code_len: float
Calculate the average code length per source symbol.
- Returns:
Average number of channel symbols per source symbol, or 0.0 if no source symbols have been processed
- __init__(total_messages=0, successful_messages=0, decoded_messages=0, failed_messages=0, total_source_symbols=0, total_channel_symbols=0, decode_errors=0, validation_errors=0, total_processing_time=0.0, avg_message_time=0.0)
- class codinglab.receivers.tracking.TrackingReceiver(decoder, logger=<codinglab.logger.NullLogger object>)[source]
Bases:
Receiver[SourceChar,ChannelChar]Receiver that tracks detailed statistics about message reception.
This receiver not only decodes messages but also collects extensive statistics about the reception process, including timing information, success rates, and compression metrics. It’s ideal for experimental analysis and performance evaluation.
Note: stats will not contain failed_messages and successful_messages if logger does not have method
check_messageas their value can be computed based only on knowing messages sent by sender.- Parameters:
decoder (Decoder[SourceChar, ChannelChar])
logger (TransmissionLogger)
- __init__(decoder, logger=<codinglab.logger.NullLogger object>)[source]
Initialize the tracking receiver.
- Parameters:
decoder (
Decoder[TypeVar(SourceChar),TypeVar(ChannelChar)]) – Decoder instance for converting channel symbols back to source messageslogger (
TransmissionLogger) – Logger for recording transmission events (defaults to NullLogger)
- Return type:
None
- receive_stream(messages)[source]
Receive, decode, and track statistics for a stream of messages.
This implementation decodes each message, tracks detailed statistics about the decoding process, logs events, and yields True for successful decoding or False for failures.
- Parameters:
messages (
Iterator[Message[TypeVar(ChannelChar)]]) – Iterator of messages received from a channel- Yields:
True for each successfully received and decoded message, False for messages that failed to decode
- Return type:
Note
All statistics are updated incrementally as messages are processed, allowing real-time monitoring of performance.