Get top N slowest operations. Returns: List of (operation_type, detail, time_ms) e.g., ('ParseClass', 'fl::string', 129.4)
(self, n: int = 20)
| 256 | return sorted(fastled_headers, key=lambda x: x[1], reverse=True) |
| 257 | |
| 258 | def get_top_operations(self, n: int = 20) -> list[tuple[str, str, float]]: |
| 259 | """ |
| 260 | Get top N slowest operations. |
| 261 | |
| 262 | Returns: |
| 263 | List of (operation_type, detail, time_ms) |
| 264 | e.g., ('ParseClass', 'fl::string', 129.4) |
| 265 | """ |
| 266 | operations: list[tuple[str, str, float]] = [] |
| 267 | |
| 268 | for event in self.events: |
| 269 | name = event.get("name", "") |
| 270 | dur = event.get("dur", 0) |
| 271 | detail = event.get("args", {}).get("detail", "") |
| 272 | |
| 273 | # Skip very short operations |
| 274 | if dur < 1000: # Less than 1ms |
| 275 | continue |
| 276 | |
| 277 | # Include interesting operations |
| 278 | if any( |
| 279 | keyword in name |
| 280 | for keyword in ["Parse", "Instantiate", "Source", "Template"] |
| 281 | ): |
| 282 | if name == "Source": |
| 283 | detail = self._extract_header_name(detail) |
| 284 | operations.append((name, detail, dur / 1000.0)) |
| 285 | |
| 286 | # Sort by time and return top N |
| 287 | operations.sort(key=lambda x: x[2], reverse=True) |
| 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.""" |
no test coverage detected