performance improvements and formatting cleanup

This commit is contained in:
2025-08-11 22:37:46 -07:00
parent c3f81eef25
commit d69a4104fc
10 changed files with 141 additions and 75 deletions
+8 -8
View File
@@ -24,7 +24,7 @@ use crate::types::Metrics;
use crate::ui::cpu::{
draw_cpu_avg_graph, draw_per_core_bars, per_core_clamp, per_core_content_area,
per_core_handle_key, per_core_handle_mouse, per_core_handle_scrollbar_mouse,
PerCoreScrollDrag,
PerCoreScrollDrag
};
use crate::ui::{
disks::draw_disks,
@@ -32,7 +32,7 @@ use crate::ui::{
mem::draw_mem,
net::draw_net_spark,
processes::draw_top_processes,
swap::draw_swap,
swap::draw_swap
};
use crate::ui::gpu::draw_gpu;
use crate::ws::{connect, request_metrics};
@@ -74,7 +74,7 @@ impl App {
tx_peak: 0,
should_quit: false,
per_core_scroll: 0,
per_core_drag: None,
per_core_drag: None
}
}
@@ -125,7 +125,7 @@ impl App {
Constraint::Ratio(1, 3),
Constraint::Length(3),
Constraint::Length(3),
Constraint::Min(10),
Constraint::Min(10)
])
.split(area);
let top = ratatui::layout::Layout::default()
@@ -154,7 +154,7 @@ impl App {
Constraint::Ratio(1, 3),
Constraint::Length(3),
Constraint::Length(3),
Constraint::Min(10),
Constraint::Min(10)
])
.split(area);
let top = ratatui::layout::Layout::default()
@@ -256,7 +256,7 @@ impl App {
Constraint::Ratio(1, 3), // top row
Constraint::Length(3), // memory (left) + GPU (right, part 1)
Constraint::Length(3), // swap (left) + GPU (right, part 2)
Constraint::Min(10), // bottom: disks + net (left), top procs (right)
Constraint::Min(10) // bottom: disks + net (left), top procs (right)
])
.split(area);
@@ -313,7 +313,7 @@ impl App {
.constraints([
Constraint::Min(7), // Disks grow
Constraint::Length(3), // Download
Constraint::Length(3), // Upload
Constraint::Length(3) // Upload
])
.split(bottom_lr[0]);
@@ -359,7 +359,7 @@ impl Default for App {
tx_peak: 0,
should_quit: false,
per_core_scroll: 0,
per_core_drag: None,
per_core_drag: None
}
}
}
+2 -2
View File
@@ -100,7 +100,7 @@ pub fn per_core_handle_scrollbar_mouse(
drag: &mut Option<PerCoreScrollDrag>,
mouse: MouseEvent,
per_core_area: Rect,
total_rows: usize,
total_rows: usize
) {
// Geometry
let inner = Rect {
@@ -265,7 +265,7 @@ pub fn draw_per_core_bars(
area: Rect,
m: Option<&Metrics>,
per_core_hist: &PerCoreHistory,
scroll_offset: usize,
scroll_offset: usize
) {
f.render_widget(
Block::default().borders(Borders::ALL).title("Per-core"),
+2 -2
View File
@@ -2,7 +2,7 @@ use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Style},
text::Span,
widgets::{Block, Borders, Gauge, Paragraph},
widgets::{Block, Borders, Gauge, Paragraph}
};
use crate::types::Metrics;
@@ -110,7 +110,7 @@ pub fn draw_gpu(f: &mut ratatui::Frame<'_>, area: Rect, m: Option<&Metrics>) {
f.render_widget(
Paragraph::new(Span::raw(format!("vram: {used_s}/{total_s} ({mem_pct}%)")))
.style(Style::default().fg(Color::Gray)),
mem_cols[1],
mem_cols[1]
);
}
}
+2 -2
View File
@@ -3,7 +3,7 @@
use ratatui::{
layout::Rect,
style::{Color, Style},
widgets::{Block, Borders, Sparkline},
widgets::{Block, Borders, Sparkline}
};
use std::collections::VecDeque;
@@ -12,7 +12,7 @@ pub fn draw_net_spark(
area: Rect,
title: &str,
hist: &VecDeque<u64>,
color: Color,
color: Color
) {
let max_points = area.width.saturating_sub(2) as usize;
let start = hist.len().saturating_sub(max_points);