Skip to content

Commit 9ec99b3

Browse files
committed
address issues
Signed-off-by: chang-ning <spiderpower02@gmail.com>
1 parent a7523d3 commit 9ec99b3

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/gpu.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ pub struct GpuMetrics {
1111
pub power_w: Option<f64>,
1212
pub clock_mhz: Option<u32>,
1313
}
14+
15+
impl GpuMetrics {
16+
/// True when no reading is available at all; readers report None then,
17+
/// so the UI skips the gauge line instead of rendering all dashes.
18+
pub fn is_empty(&self) -> bool {
19+
*self == Self::default()
20+
}
21+
}

src/nvlink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn read_device_snapshot(nvml: &Nvml, idx: u32) -> Option<NvLinkSnapshot> {
281281
Some(NvLinkSnapshot {
282282
gpu_index: idx,
283283
gpu_name,
284-
metrics: Some(read_gpu_metrics(&device)),
284+
metrics: Some(read_gpu_metrics(&device)).filter(|m| !m.is_empty()),
285285
link_count,
286286
link_gbps: if total_speed_gbps > 0.0 {
287287
Some(total_speed_gbps)

src/tui/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ fn draw_table(frame: &mut Frame, app: &mut App, area: Rect, tc: &ThemeColors) {
759759
}
760760

761761
fn sparkline_str(data: &[f64], width: usize) -> String {
762-
let max = data.iter().cloned().fold(0.0f64, f64::max);
762+
let max = data.iter().copied().fold(0.0f64, f64::max);
763763
sparkline_scaled(data, width, max)
764764
}
765765

src/xgmi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ fn read_processor_snapshot(
527527
link_gbps: (total_gbps > 0.0).then_some(total_gbps),
528528
correctable_errors,
529529
uncorrectable_errors,
530-
metrics: Some(read_gpu_metrics(api, handle)),
530+
metrics: Some(read_gpu_metrics(api, handle)).filter(|m| !m.is_empty()),
531531
links,
532532
})
533533
}

0 commit comments

Comments
 (0)