Testing
This commit is contained in:
@@ -149,18 +149,57 @@ impl SystemCollector {
|
||||
}
|
||||
|
||||
if total_time > 0 && !cstate_times.is_empty() {
|
||||
// Sort by time spent (highest first)
|
||||
cstate_times.sort_by(|a, b| b.1.cmp(&a.1));
|
||||
// Sort by C-state order: POLL, C1, C1E, C3, C6, C7s, C8, C9, C10
|
||||
cstate_times.sort_by(|a, b| {
|
||||
let order_a = match a.0.as_str() {
|
||||
"POLL" => 0,
|
||||
"C1" => 1,
|
||||
"C1E" => 2,
|
||||
"C3" => 3,
|
||||
"C6" => 4,
|
||||
"C7s" => 5,
|
||||
"C8" => 6,
|
||||
"C9" => 7,
|
||||
"C10" => 8,
|
||||
_ => 99,
|
||||
};
|
||||
let order_b = match b.0.as_str() {
|
||||
"POLL" => 0,
|
||||
"C1" => 1,
|
||||
"C1E" => 2,
|
||||
"C3" => 3,
|
||||
"C6" => 4,
|
||||
"C7s" => 5,
|
||||
"C8" => 6,
|
||||
"C9" => 7,
|
||||
"C10" => 8,
|
||||
_ => 99,
|
||||
};
|
||||
order_a.cmp(&order_b)
|
||||
});
|
||||
|
||||
// Format all C-states with percentages
|
||||
// Format C-states as description lines (split into two rows for readability)
|
||||
let mut result = Vec::new();
|
||||
let mut current_line = Vec::new();
|
||||
|
||||
for (name, time) in cstate_times {
|
||||
let percent = (time as f32 / total_time as f32) * 100.0;
|
||||
if percent >= 0.1 { // Only show states with at least 0.1% time
|
||||
result.push(format!("{}: {:.1}%", name, percent));
|
||||
current_line.push(format!("{}: {:.1}%", name, percent));
|
||||
|
||||
// Split into two rows when we have 4 items
|
||||
if current_line.len() == 4 {
|
||||
result.push(current_line.join(", "));
|
||||
current_line.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add remaining items as second line
|
||||
if !current_line.is_empty() {
|
||||
result.push(current_line.join(", "));
|
||||
}
|
||||
|
||||
return Some(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user