Format timing information as a table.
(self)
| 75 | self.total_time = time.time() - cp["start"] |
| 76 | |
| 77 | def format_table(self) -> str: |
| 78 | """Format timing information as a table.""" |
| 79 | self.calculate_phases() |
| 80 | |
| 81 | # Only show phases that have meaningful timing |
| 82 | phases = [] |
| 83 | |
| 84 | if self.meson_setup_time > 0: |
| 85 | phases.append(("Meson Setup", self.meson_setup_time)) |
| 86 | |
| 87 | if self.ninja_maintenance_time > 0: |
| 88 | phases.append(("Ninja Maintenance", self.ninja_maintenance_time)) |
| 89 | |
| 90 | if self.compile_time > 0: |
| 91 | phases.append(("Compilation", self.compile_time)) |
| 92 | |
| 93 | if self.test_execution_time > 0: |
| 94 | phases.append(("Test Execution", self.test_execution_time)) |
| 95 | |
| 96 | if not phases: |
| 97 | return "" |
| 98 | |
| 99 | # Build table |
| 100 | lines = [] |
| 101 | lines.append("") |
| 102 | lines.append("┌─ Build Timing Breakdown ─────────────────┐") |
| 103 | |
| 104 | # Find max label width for alignment |
| 105 | max_label_width = max(len(label) for label, _ in phases) |
| 106 | |
| 107 | for label, duration in phases: |
| 108 | percentage = ( |
| 109 | (duration / self.total_time * 100) if self.total_time > 0 else 0 |
| 110 | ) |
| 111 | bar_width = int(percentage / 5) # 20 chars = 100% |
| 112 | bar = "█" * bar_width + "░" * (20 - bar_width) |
| 113 | |
| 114 | lines.append( |
| 115 | f"│ {label:<{max_label_width}} {duration:>6.2f}s [{bar}] {percentage:>5.1f}%" |
| 116 | ) |
| 117 | |
| 118 | lines.append("├───────────────────────────────────────────┤") |
| 119 | lines.append(f"│ {'Total':<{max_label_width}} {self.total_time:>6.2f}s") |
| 120 | lines.append("└───────────────────────────────────────────┘") |
| 121 | |
| 122 | return "\n".join(lines) |
| 123 | |
| 124 | def format_simple(self) -> str: |
| 125 | """Format timing as simple summary line.""" |
no test coverage detected