Build + bloat one config; return total_flash or None on failure.
(cfg: OptInConfig, example: str)
| 345 | |
| 346 | |
| 347 | def measure_one(cfg: OptInConfig, example: str) -> int | None: |
| 348 | """Build + bloat one config; return total_flash or None on failure.""" |
| 349 | print(f"\n=== measure-opt-ins: config {cfg.name} ({cfg.label}) ===", flush=True) |
| 350 | restore_platformio_ini(keep_backup=True) |
| 351 | patch_platformio_ini(cfg) |
| 352 | _force_relink() |
| 353 | if not run_compile(example, cfg.name): |
| 354 | print(f"measure-opt-ins: compile failed for {cfg.name}", file=sys.stderr) |
| 355 | return None |
| 356 | if not run_bloat(cfg.name): |
| 357 | print(f"measure-opt-ins: bloat run failed for {cfg.name}", file=sys.stderr) |
| 358 | return None |
| 359 | total = read_total_flash() |
| 360 | if total is None: |
| 361 | print( |
| 362 | f"measure-opt-ins: report.json missing after {cfg.name} bloat run", |
| 363 | file=sys.stderr, |
| 364 | ) |
| 365 | return None |
| 366 | archived = archive_report(cfg) |
| 367 | print( |
| 368 | f"measure-opt-ins: {cfg.name} total_flash = {total:,} B " |
| 369 | f"(report archived: {archived.relative_to(PROJECT_ROOT).as_posix()})", |
| 370 | flush=True, |
| 371 | ) |
| 372 | return total |
| 373 | |
| 374 | |
| 375 | def format_table(results: dict[str, int]) -> str: |
no test coverage detected