Print binary I/O encoding statistics.
(self, collector)
| 302 | print(f" {ANSIColors.YELLOW}Stale cache invalidations: {stale_invalidations}{ANSIColors.RESET}") |
| 303 | |
| 304 | def _print_binary_stats(self, collector): |
| 305 | """Print binary I/O encoding statistics.""" |
| 306 | try: |
| 307 | stats = collector.get_stats() |
| 308 | except (ValueError, RuntimeError): |
| 309 | return # Collector closed or stats unavailable |
| 310 | |
| 311 | print(f" {ANSIColors.CYAN}Binary Encoding:{ANSIColors.RESET}") |
| 312 | |
| 313 | repeat_records = stats.get('repeat_records', 0) |
| 314 | repeat_samples = stats.get('repeat_samples', 0) |
| 315 | full_records = stats.get('full_records', 0) |
| 316 | suffix_records = stats.get('suffix_records', 0) |
| 317 | pop_push_records = stats.get('pop_push_records', 0) |
| 318 | total_records = stats.get('total_records', 0) |
| 319 | |
| 320 | if total_records > 0: |
| 321 | repeat_pct = repeat_records / total_records * 100 |
| 322 | full_pct = full_records / total_records * 100 |
| 323 | suffix_pct = suffix_records / total_records * 100 |
| 324 | pop_push_pct = pop_push_records / total_records * 100 |
| 325 | else: |
| 326 | repeat_pct = full_pct = suffix_pct = pop_push_pct = 0 |
| 327 | |
| 328 | print(f" Records: {total_records:,}") |
| 329 | print(f" RLE repeat: {repeat_records:,} ({ANSIColors.GREEN}{repeat_pct:.1f}%{ANSIColors.RESET}) [{repeat_samples:,} samples]") |
| 330 | print(f" Full stack: {full_records:,} ({full_pct:.1f}%)") |
| 331 | print(f" Suffix match: {suffix_records:,} ({suffix_pct:.1f}%)") |
| 332 | print(f" Pop-push: {pop_push_records:,} ({pop_push_pct:.1f}%)") |
| 333 | |
| 334 | frames_written = stats.get('total_frames_written', 0) |
| 335 | frames_saved = stats.get('frames_saved', 0) |
| 336 | compression_pct = stats.get('frame_compression_pct', 0) |
| 337 | |
| 338 | print(f" {ANSIColors.CYAN}Frame Efficiency:{ANSIColors.RESET}") |
| 339 | print(f" Frames written: {frames_written:,}") |
| 340 | print(f" Frames saved: {frames_saved:,} ({ANSIColors.GREEN}{compression_pct:.1f}%{ANSIColors.RESET})") |
| 341 | |
| 342 | bytes_written = stats.get('bytes_written', 0) |
| 343 | if bytes_written >= 1024 * 1024: |
| 344 | bytes_str = f"{bytes_written / (1024 * 1024):.1f} MB" |
| 345 | elif bytes_written >= 1024: |
| 346 | bytes_str = f"{bytes_written / 1024:.1f} KB" |
| 347 | else: |
| 348 | bytes_str = f"{bytes_written} B" |
| 349 | print(f" Bytes (pre-zstd): {bytes_str}") |
| 350 | |
| 351 | |
| 352 | def _is_process_running(pid): |