Print a formatted summary of build times
(self)
| 118 | self.logger(f"Build times saved to {output_file}") |
| 119 | |
| 120 | def print_summary(self): |
| 121 | """Print a formatted summary of build times""" |
| 122 | summary = self.get_summary() |
| 123 | |
| 124 | self.logger("\n" + "="*60) |
| 125 | self.logger("BUILD TIME SUMMARY") |
| 126 | self.logger("="*60) |
| 127 | |
| 128 | # Command times |
| 129 | if self.command_times: |
| 130 | self.logger("COMMAND TIMES:") |
| 131 | for cmd, data in sorted(self.command_times.items(), key=lambda x: x[1]['duration'], reverse=True): |
| 132 | self.logger(f" {cmd:<20} {data['duration']:>8.2f} s") |
| 133 | |
| 134 | # Component times in tabular format |
| 135 | if self.component_times: |
| 136 | # Get all unique platforms |
| 137 | all_platforms = set() |
| 138 | for platforms in self.component_times.values(): |
| 139 | all_platforms.update(platforms.keys()) |
| 140 | |
| 141 | if all_platforms: |
| 142 | # Sort platforms alphabetically |
| 143 | sorted_platforms = sorted(all_platforms) |
| 144 | |
| 145 | # Calculate column widths |
| 146 | component_width = 15 |
| 147 | platform_width = 12 # "8.2f s" = 8 chars + 2 chars = 10, plus 2 for spacing |
| 148 | |
| 149 | # Create header with all platforms |
| 150 | header = f"{'COMPONENTS:':<{component_width}} " |
| 151 | for platform in sorted_platforms: |
| 152 | header += f"{platform:<{platform_width}} " |
| 153 | header += "TOTAL AVERAGE" |
| 154 | self.logger(f"\n{header}") |
| 155 | |
| 156 | # Get all components that have data for any platform |
| 157 | all_components = set() |
| 158 | for component, platforms in self.component_times.items(): |
| 159 | all_components.add(component) |
| 160 | |
| 161 | # Sort components by total time (descending) |
| 162 | sorted_components = [] |
| 163 | for component in all_components: |
| 164 | platforms = self.component_times[component] |
| 165 | total_duration = sum(platform_data['duration'] for platform_data in platforms.values()) |
| 166 | sorted_components.append((component, total_duration)) |
| 167 | |
| 168 | sorted_components.sort(key=lambda x: x[1], reverse=True) |
| 169 | |
| 170 | for component, total_duration in sorted_components: |
| 171 | platforms = self.component_times[component] |
| 172 | avg_duration = total_duration / len(platforms) |
| 173 | |
| 174 | # Build the line with all platform times |
| 175 | line = f"{component:<{component_width}} " |
| 176 | for platform in sorted_platforms: |
| 177 | if platform in platforms: |