Build nested tree of header includes up to max_depth levels deep.
(self, max_depth: int = 3)
| 288 | return operations[:n] |
| 289 | |
| 290 | def build_header_tree(self, max_depth: int = 3) -> dict[str, Any]: |
| 291 | """Build nested tree of header includes up to max_depth levels deep.""" |
| 292 | headers = self.get_header_times(max_depth=max_depth + 1) |
| 293 | |
| 294 | def build_subtree(header_name: str, current_depth: int) -> dict[str, Any]: |
| 295 | """Recursively build tree for a header and its children.""" |
| 296 | if header_name not in headers: |
| 297 | return {"time": 0, "children": {}} |
| 298 | |
| 299 | info = headers[header_name] |
| 300 | node: dict[str, Any] = {"time": info["time"], "children": {}} |
| 301 | |
| 302 | # Only recurse if we haven't hit max depth |
| 303 | if current_depth < max_depth: |
| 304 | for child_name in info["children"]: |
| 305 | node["children"][child_name] = build_subtree( |
| 306 | child_name, current_depth + 1 |
| 307 | ) |
| 308 | |
| 309 | return node |
| 310 | |
| 311 | # Find root headers (depth 0 or 1) |
| 312 | tree: dict[str, Any] = {} |
| 313 | for name, info in headers.items(): |
| 314 | if info["depth"] <= 1: |
| 315 | tree[name] = build_subtree(name, 0) |
| 316 | |
| 317 | return tree |
| 318 | |
| 319 | def generate_report( |
| 320 | self, format_type: str = "text", threshold_ms: float = 50.0 |
no test coverage detected