Context manager for timing code execution. This utility function measures the execution time of code within its context and accumulates the timing information in the provided dictionary. Args: name (str): The name/identifier for this timing measurement. timing_raw (Dict
(name: str, timing_raw: Dict[str, float])
| 106 | |
| 107 | @contextmanager |
| 108 | def _timer(name: str, timing_raw: Dict[str, float]): |
| 109 | """Context manager for timing code execution. |
| 110 | |
| 111 | This utility function measures the execution time of code within its context |
| 112 | and accumulates the timing information in the provided dictionary. |
| 113 | |
| 114 | Args: |
| 115 | name (str): The name/identifier for this timing measurement. |
| 116 | timing_raw (Dict[str, float]): Dictionary to store timing information. |
| 117 | |
| 118 | Yields: |
| 119 | None: This is a context manager that yields control back to the code block. |
| 120 | """ |
| 121 | with Timer(name=name, logger=None) as timer: |
| 122 | yield |
| 123 | if name not in timing_raw: |
| 124 | timing_raw[name] = 0 |
| 125 | timing_raw[name] += timer.last |
| 126 | |
| 127 | |
| 128 | def reduce_timing(timing_raw: Dict[str, float]) -> Dict[str, float]: |
no outgoing calls
no test coverage detected