redbear-power: CPU frequency color coding in per-CPU table
Freq column now color-graded based on P-state range: dark gray at lowest P-state (<=15% of range) default mid-range yellow >=50% of range red+bold >=85% of range (turbo/high)
This commit is contained in:
@@ -1818,8 +1818,26 @@ pub fn render_cpu_table<'a>(
|
||||
let rows: Vec<Row> = cpus
|
||||
.iter()
|
||||
.map(|cpu| {
|
||||
let freq_mhz = cpu.freq_khz / 1000;
|
||||
let freq_style = if !cpu.pstates.is_empty() {
|
||||
let max_f = cpu.pstates.first().map(|p| p.freq_khz).unwrap_or(0) / 1000;
|
||||
let min_f = cpu.pstates.last().map(|p| p.freq_khz).unwrap_or(0) / 1000;
|
||||
if max_f > min_f && freq_mhz > 0 {
|
||||
let pct = (freq_mhz - min_f) as f64 * 100.0 / (max_f - min_f) as f64;
|
||||
match pct as u32 {
|
||||
p if p >= 85 => theme::VALUE_HOT,
|
||||
p if p >= 50 => theme::VALUE_WARM,
|
||||
p if p <= 15 => Style::new().dark_gray(),
|
||||
_ => theme::VALUE,
|
||||
}
|
||||
} else {
|
||||
theme::VALUE
|
||||
}
|
||||
} else {
|
||||
theme::VALUE
|
||||
};
|
||||
let freq = if cpu.freq_khz > 0 {
|
||||
format!("{}", cpu.freq_khz / 1000)
|
||||
format!("{}", freq_mhz)
|
||||
} else {
|
||||
"?".into()
|
||||
};
|
||||
@@ -1879,7 +1897,7 @@ pub fn render_cpu_table<'a>(
|
||||
format!("{}{}", cpuid::core_type_label(cpu.core_type), cpu.id)
|
||||
.set_style(theme::VALUE),
|
||||
),
|
||||
Cell::from(freq.set_style(theme::VALUE)),
|
||||
Cell::from(freq.set_style(freq_style)),
|
||||
Cell::from(
|
||||
pkg_power_w
|
||||
.map(|w| format!("{w:.1}"))
|
||||
|
||||
Reference in New Issue
Block a user