mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-09-27 13:05:44 +00:00
fix potential logic bug with generate points logic, but this isn't the actual issue
This commit is contained in:
+2
-1
@@ -20,7 +20,7 @@ That said, these are more guidelines rather than hardset rules, though the proje
|
||||
|
||||
---
|
||||
|
||||
## [0.11.3]/[0.12.0] - Unreleased
|
||||
## [0.11.3] - Unreleased
|
||||
|
||||
### Features
|
||||
|
||||
@@ -30,6 +30,7 @@ That said, these are more guidelines rather than hardset rules, though the proje
|
||||
|
||||
- [#1833](https://github.com/ClementTsang/bottom/pull/1833): Sort disk I/O using actual value rather than string representation.
|
||||
- [#1812](https://github.com/ClementTsang/bottom/pull/1812): Fix ARC collection on FreeBSD.
|
||||
- [](): Fix displayed average CPU value being wrong in graphs.
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ impl App {
|
||||
|
||||
for cpu in self.states.cpu_state.widget_states.values_mut() {
|
||||
if cpu.force_update_data {
|
||||
cpu.set_legend_data(&data_source.cpu_harvest);
|
||||
cpu.set_legend_data(&data_source.cpu_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct StoredData {
|
||||
pub arc_harvest: Option<MemData>,
|
||||
#[cfg(feature = "gpu")]
|
||||
pub gpu_harvest: Vec<(String, MemData)>,
|
||||
pub cpu_harvest: Vec<cpu::CpuData>,
|
||||
pub cpu_data: Vec<cpu::CpuData>,
|
||||
pub load_avg_harvest: cpu::LoadAvgHarvest,
|
||||
pub process_data: ProcessData,
|
||||
/// TODO: (points_rework_v1) Might be a better way to do this without having to store here?
|
||||
@@ -50,7 +50,7 @@ impl Default for StoredData {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
cache_harvest: None,
|
||||
swap_harvest: None,
|
||||
cpu_harvest: Default::default(),
|
||||
cpu_data: Default::default(),
|
||||
load_avg_harvest: cpu::LoadAvgHarvest::default(),
|
||||
process_data: Default::default(),
|
||||
prev_io: Vec::default(),
|
||||
@@ -113,16 +113,16 @@ impl StoredData {
|
||||
}
|
||||
|
||||
if let Some(cpu) = data.cpu {
|
||||
self.cpu_harvest.clear();
|
||||
self.cpu_data.clear();
|
||||
|
||||
if let Some(avg) = cpu.avg {
|
||||
self.cpu_harvest.push(cpu::CpuData {
|
||||
self.cpu_data.push(cpu::CpuData {
|
||||
data_type: cpu::CpuDataType::Avg,
|
||||
usage: avg,
|
||||
});
|
||||
}
|
||||
|
||||
self.cpu_harvest
|
||||
self.cpu_data
|
||||
.extend(
|
||||
cpu.cpus
|
||||
.into_iter()
|
||||
|
||||
@@ -103,6 +103,8 @@ impl TimeSeriesData {
|
||||
// If there isn't avg then we never had any to begin with.
|
||||
if let Some(avg) = cpu_harvest.avg {
|
||||
self.avg_cpu.push(avg.into());
|
||||
} else {
|
||||
self.avg_cpu.insert_break();
|
||||
}
|
||||
} else {
|
||||
for c in &mut self.cpu {
|
||||
|
||||
+1
-1
@@ -244,7 +244,7 @@ impl Painter {
|
||||
}
|
||||
|
||||
let data = app_state.data_store.get_data();
|
||||
let actual_cpu_data_len = data.cpu_harvest.len();
|
||||
let actual_cpu_data_len = data.cpu_data.len();
|
||||
|
||||
// This fixes #397, apparently if the height is 1, it can't render the CPU
|
||||
// bars...
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Painter {
|
||||
pub fn draw_basic_cpu(
|
||||
&self, f: &mut Frame<'_>, app_state: &mut App, mut draw_loc: Rect, widget_id: u64,
|
||||
) {
|
||||
let cpu_data = &app_state.data_store.get_data().cpu_harvest;
|
||||
let cpu_data = &app_state.data_store.get_data().cpu_data;
|
||||
|
||||
// This is a bit complicated, but basically, we want to draw SOME number
|
||||
// of columns to draw all CPUs. Ideally, as well, we want to not have
|
||||
|
||||
@@ -120,7 +120,7 @@ impl Painter {
|
||||
&self, cpu_widget_state: &'a CpuWidgetState, data: &'a StoredData, show_avg_cpu: bool,
|
||||
) -> Vec<GraphData<'a>> {
|
||||
let current_scroll_position = cpu_widget_state.table.state.current_index;
|
||||
let cpu_entries = &data.cpu_harvest;
|
||||
let cpu_entries = &data.cpu_data;
|
||||
let cpu_points = &data.timeseries_data.cpu;
|
||||
let time = &data.timeseries_data.time;
|
||||
|
||||
@@ -152,36 +152,33 @@ impl Painter {
|
||||
}
|
||||
|
||||
points
|
||||
} else if let Some(CpuData { .. }) = cpu_entries.get(current_scroll_position - 1) {
|
||||
// We generally subtract one from current scroll position because of the all entry.
|
||||
} else if show_avg_cpu && current_scroll_position == AVG_POSITION {
|
||||
let style = self.styles.avg_cpu_colour;
|
||||
|
||||
let show_avg_offset = if show_avg_cpu { AVG_POSITION } else { 0 };
|
||||
let is_avg = show_avg_cpu && current_scroll_position == AVG_POSITION;
|
||||
|
||||
let style = if is_avg {
|
||||
self.styles.avg_cpu_colour
|
||||
} else {
|
||||
self.styles.cpu_colour_styles[(current_scroll_position - 1 - show_avg_offset)
|
||||
% self.styles.cpu_colour_styles.len()]
|
||||
};
|
||||
|
||||
if is_avg {
|
||||
vec![
|
||||
GraphData::default()
|
||||
.style(style)
|
||||
.time(time)
|
||||
.values(&data.timeseries_data.avg_cpu),
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
GraphData::default()
|
||||
.style(style)
|
||||
.time(time)
|
||||
.values(&cpu_points[current_scroll_position - 1 - show_avg_offset]),
|
||||
]
|
||||
}
|
||||
vec![
|
||||
GraphData::default()
|
||||
.style(style)
|
||||
.time(time)
|
||||
.values(&data.timeseries_data.avg_cpu),
|
||||
]
|
||||
} else {
|
||||
vec![]
|
||||
// Note, we generally subtract one from current scroll position because of the all entry.
|
||||
let show_avg_offset = if show_avg_cpu { AVG_POSITION } else { 0 };
|
||||
let corrected_offset = current_scroll_position - 1 - show_avg_offset;
|
||||
|
||||
if let Some(CpuData { .. }) = cpu_entries.get(corrected_offset) {
|
||||
let style = self.styles.cpu_colour_styles
|
||||
[(corrected_offset) % self.styles.cpu_colour_styles.len()];
|
||||
|
||||
vec![
|
||||
GraphData::default()
|
||||
.style(style)
|
||||
.time(time)
|
||||
.values(&cpu_points[corrected_offset]),
|
||||
]
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user