Get header parse times with nesting information. IMPORTANT: Returns CUMULATIVE time (total time including all nested includes). This is the full duration from when the compiler starts processing the header until it finishes, including all headers it includes recursi
(self, max_depth: int = 2)
| 163 | return Path(path).name |
| 164 | |
| 165 | def get_header_times(self, max_depth: int = 2) -> dict[str, Any]: |
| 166 | """ |
| 167 | Get header parse times with nesting information. |
| 168 | |
| 169 | IMPORTANT: Returns CUMULATIVE time (total time including all nested includes). |
| 170 | This is the full duration from when the compiler starts processing the header |
| 171 | until it finishes, including all headers it includes recursively. |
| 172 | |
| 173 | Returns: |
| 174 | Dict mapping header name to: |
| 175 | { |
| 176 | 'time': float, # CUMULATIVE milliseconds (includes nested headers) |
| 177 | 'path': str, # full path |
| 178 | 'depth': int, # nesting level |
| 179 | 'parent': str, # parent header |
| 180 | 'children': List[str] # child headers |
| 181 | } |
| 182 | """ |
| 183 | headers: dict[str, dict[str, Any]] = {} |
| 184 | |
| 185 | # Sort events by timestamp |
| 186 | sorted_sources = sorted(self.source_events, key=lambda e: e.get("ts", 0)) |
| 187 | |
| 188 | # Build parent-child relationships |
| 189 | stack: list[tuple[str, int, int]] = [] # (path, start_ts, end_ts) |
| 190 | |
| 191 | for event in sorted_sources: |
| 192 | path = event.get("args", {}).get("detail", "") |
| 193 | if not path: |
| 194 | continue |
| 195 | |
| 196 | ts = event.get("ts", 0) |
| 197 | dur = event.get("dur", 0) |
| 198 | end_ts = ts + dur |
| 199 | |
| 200 | # Find parent (last event that contains this timestamp) |
| 201 | parent = None |
| 202 | depth = 0 |
| 203 | |
| 204 | # Clean up stack (remove events that have ended) |
| 205 | while stack and stack[-1][2] <= ts: |
| 206 | stack.pop() |
| 207 | |
| 208 | if stack: |
| 209 | parent = stack[-1][0] |
| 210 | depth = len(stack) |
| 211 | |
| 212 | stack.append((path, ts, end_ts)) |
| 213 | |
| 214 | header_name = self._extract_header_name(path) |
| 215 | |
| 216 | if header_name not in headers: |
| 217 | headers[header_name] = { |
| 218 | "time": dur / 1000.0, |
| 219 | "path": path, |
| 220 | "depth": depth, |
| 221 | "parent": self._extract_header_name(parent) if parent else None, |
| 222 | "children": [], |
no test coverage detected