diff --git a/crates/launchbound-cli/src/main.rs b/crates/launchbound-cli/src/main.rs index ef274a3..dd6d9ce 100644 --- a/crates/launchbound-cli/src/main.rs +++ b/crates/launchbound-cli/src/main.rs @@ -420,7 +420,7 @@ fn cmd_tune( )?; let dev = device(cc)?; println!( - "{} — ESTIMATED tuning (analytical model, cc {cc}); the gate is full, the timings are NOT measurements:", + "{} — ESTIMATED tuning (analytical model, cc {cc}); the gate is full, the timings are NOT measurements:", spec.name ); let mut admitted: Vec<_> = verdicts diff --git a/crates/launchbound-tui/src/app.rs b/crates/launchbound-tui/src/app.rs index 885424a..387c303 100644 --- a/crates/launchbound-tui/src/app.rs +++ b/crates/launchbound-tui/src/app.rs @@ -108,6 +108,22 @@ fn draw_header(frame: &mut Frame<'_>, app: &App, area: Rect) { frame.render_widget(Paragraph::new(lines), area); } +/// The banner above the field when refused configurations measured faster. +/// +/// A function rather than an inline `format!` so both arities can be tested. +/// The count comes from measured timings, and the one fixture the golden +/// frames are built on yields exactly one — so the plural branch is not +/// reachable from a rendered frame without rebuilding that fixture, which +/// would move every golden in the suite to cover two words. +fn refused_faster_banner(count: usize) -> String { + let noun = if count == 1 { + "configuration" + } else { + "configurations" + }; + format!("{count} REFUSED {noun} measured FASTER than the chosen one — view 3") +} + fn draw_overview(frame: &mut Frame<'_>, app: &App, area: Rect) { let r = &app.report; let mut lines = Vec::new(); @@ -133,10 +149,7 @@ fn draw_overview(frame: &mut Frame<'_>, app: &App, area: Rect) { if !r.rejected_faster.is_empty() { lines.push(Line::from("")); lines.push(Line::from(Span::styled( - format!( - "{} REFUSED configuration(s) measured FASTER than the chosen one — view 3", - r.rejected_faster.len() - ), + refused_faster_banner(r.rejected_faster.len()), Style::default().add_modifier(Modifier::BOLD), ))); } @@ -363,3 +376,23 @@ fn bar(done: usize, total: usize, width: usize) -> String { } s } + +#[cfg(test)] +mod tests { + use super::refused_faster_banner; + + #[test] + fn the_refused_faster_banner_agrees_with_its_own_count() { + assert_eq!( + refused_faster_banner(1), + "1 REFUSED configuration measured FASTER than the chosen one — view 3" + ); + assert_eq!( + refused_faster_banner(2), + "2 REFUSED configurations measured FASTER than the chosen one — view 3" + ); + // Not reachable through the view — the banner is drawn only when the + // list is non-empty — but the function is total, so it is pinned. + assert!(refused_faster_banner(0).starts_with("0 REFUSED configurations")); + } +} diff --git a/crates/launchbound-tui/tests/golden/overview-110x32.txt b/crates/launchbound-tui/tests/golden/overview-110x32.txt index 55d9b52..f72f797 100644 --- a/crates/launchbound-tui/tests/golden/overview-110x32.txt +++ b/crates/launchbound-tui/tests/golden/overview-110x32.txt @@ -4,7 +4,7 @@ launchbound — reduce-flip · gate cc 8.6 · measured · NVIDIA A10G ┌overview────────────────────────────────────────────────────────────────────────────────────────────────────┐ │CHOSEN c1-0000000000000009 block_x=32 tile=512 unroll=4 0.0400 ms [0.0398, 0.0402] │ │ │ -│1 REFUSED configuration(s) measured FASTER than the chosen one — view 3 │ +│1 REFUSED configuration measured FASTER than the chosen one — view 3 │ │ │ │GPU-seconds consumed: 25.5 │ │ │ diff --git a/crates/launchbound-tui/tests/golden/overview-80x24.txt b/crates/launchbound-tui/tests/golden/overview-80x24.txt index c1f812d..9d2c89e 100644 --- a/crates/launchbound-tui/tests/golden/overview-80x24.txt +++ b/crates/launchbound-tui/tests/golden/overview-80x24.txt @@ -4,7 +4,7 @@ launchbound — reduce-flip · gate cc 8.6 · measured · NVIDIA A10G ┌overview──────────────────────────────────────────────────────────────────────┐ │CHOSEN c1-0000000000000009 block_x=32 tile=512 unroll=4 0.0400 ms [0.0398, │ │ │ -│1 REFUSED configuration(s) measured FASTER than the chosen one — view 3 │ +│1 REFUSED configuration measured FASTER than the chosen one — view 3 │ │ │ │GPU-seconds consumed: 25.5 │ │ │