Show top 3 C-states with usage percentages
All checks were successful
Build and Release / build-and-release (push) Successful in 1m21s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m21s
- Changed CpuData.cstate from String to Vec<CStateInfo> - Added CStateInfo struct with name and percent fields - Collector calculates percentage for each C-state based on accumulated time - Sorts and returns top 3 C-states by usage - Dashboard displays: "C10:79% C8:10% C6:8%" Provides better visibility into CPU idle state distribution. Bump version to v0.1.209 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.208"
|
||||
version = "0.1.209"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -26,7 +26,7 @@ pub struct SystemWidget {
|
||||
cpu_load_1min: Option<f32>,
|
||||
cpu_load_5min: Option<f32>,
|
||||
cpu_load_15min: Option<f32>,
|
||||
cpu_cstate: Option<String>,
|
||||
cpu_cstates: Vec<cm_dashboard_shared::CStateInfo>,
|
||||
cpu_status: Status,
|
||||
|
||||
// Memory metrics
|
||||
@@ -102,7 +102,7 @@ impl SystemWidget {
|
||||
cpu_load_1min: None,
|
||||
cpu_load_5min: None,
|
||||
cpu_load_15min: None,
|
||||
cpu_cstate: None,
|
||||
cpu_cstates: Vec::new(),
|
||||
cpu_status: Status::Unknown,
|
||||
memory_usage_percent: None,
|
||||
memory_used_gb: None,
|
||||
@@ -137,12 +137,18 @@ impl SystemWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Format CPU C-state (idle depth)
|
||||
/// Format CPU C-states (idle depth) with percentages
|
||||
fn format_cpu_cstate(&self) -> String {
|
||||
match &self.cpu_cstate {
|
||||
Some(cstate) => cstate.clone(),
|
||||
None => "—".to_string(),
|
||||
if self.cpu_cstates.is_empty() {
|
||||
return "—".to_string();
|
||||
}
|
||||
|
||||
// Format top 3 C-states with percentages: "C10:79% C8:10% C6:8%"
|
||||
self.cpu_cstates
|
||||
.iter()
|
||||
.map(|cs| format!("{}:{:.0}%", cs.name, cs.percent))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
/// Format memory usage
|
||||
@@ -188,7 +194,7 @@ impl Widget for SystemWidget {
|
||||
self.cpu_load_1min = Some(cpu.load_1min);
|
||||
self.cpu_load_5min = Some(cpu.load_5min);
|
||||
self.cpu_load_15min = Some(cpu.load_15min);
|
||||
self.cpu_cstate = Some(cpu.cstate.clone());
|
||||
self.cpu_cstates = cpu.cstates.clone();
|
||||
self.cpu_status = Status::Ok;
|
||||
|
||||
// Extract memory data directly
|
||||
|
||||
Reference in New Issue
Block a user