First implementation of cache memory display, copied from RAM and swap implementations. placed cache as second in the list as it is more similar to the RAM than any other item in the list

This commit is contained in:
Twan Stok 2023-03-13 03:28:32 +01:00
parent ba94509bef
commit dbed44198b
3 changed files with 14 additions and 1 deletions

View File

@ -239,6 +239,8 @@ fn main() -> Result<()> {
if app.used_widgets.use_mem {
app.converted_data.mem_data =
convert_mem_data_points(&app.data_collection);
app.converted_data.cache_data =
convert_cache_data_points(&app.data_collection);
app.converted_data.swap_data =
convert_swap_data_points(&app.data_collection);
#[cfg(feature = "zfs")]
@ -251,10 +253,11 @@ fn main() -> Result<()> {
app.converted_data.gpu_data =
convert_gpu_data(&app.data_collection);
}
let (memory_labels, swap_labels) =
let (memory_labels, cache_labels, swap_labels) =
convert_mem_labels(&app.data_collection);
app.converted_data.mem_labels = memory_labels;
app.converted_data.cache_labels = cache_labels;
app.converted_data.swap_labels = swap_labels;
#[cfg(feature = "zfs")]
{

View File

@ -18,6 +18,7 @@ pub struct CanvasColours {
pub currently_selected_text_style: Style,
pub table_header_style: Style,
pub ram_style: Style,
pub cache_style: Style,
pub swap_style: Style,
pub arc_style: Style,
pub gpu_colour_styles: Vec<Style>,
@ -54,6 +55,7 @@ impl Default for CanvasColours {
.bg(currently_selected_bg_colour),
table_header_style: Style::default().fg(HIGHLIGHT_COLOUR),
ram_style: Style::default().fg(FIRST_COLOUR),
cache_style: Style::default().fg(FOURTH_COLOUR),
swap_style: Style::default().fg(SECOND_COLOUR),
arc_style: Style::default().fg(THIRD_COLOUR),
gpu_colour_styles: vec![

View File

@ -56,6 +56,14 @@ impl Painter {
name: Some(mem_label.into()),
});
}
if let Some((label_percent, label_frac)) = &app_state.converted_data.cache_labels {
let cache_label = format!("CACHE:{}{}", label_percent, label_frac);
points.push(GraphData {
points: &app_state.converted_data.cache_data,
style: self.colours.cache_style,
name: Some(cache_label.into()),
});
}
if let Some((label_percent, label_frac)) = &app_state.converted_data.swap_labels {
let swap_label = format!("SWP:{}{}", label_percent, label_frac);
points.push(GraphData {