mirror of
https://github.com/danog/ytop.git
synced 2024-11-30 04:29:10 +01:00
Change process cpu usage to be overall usage
This commit is contained in:
parent
6d3381ded9
commit
af3ccdeeef
@ -1,6 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use num_rational::Ratio;
|
||||
use psutil::cpu;
|
||||
use psutil::process;
|
||||
use tui::buffer::Buffer;
|
||||
use tui::layout::{Constraint, Rect};
|
||||
@ -45,6 +46,8 @@ pub struct ProcWidget<'a> {
|
||||
sorting: ProcSorting,
|
||||
sort_direction: SortDirection,
|
||||
|
||||
cpu_count: u64,
|
||||
|
||||
procs: Vec<Proc>,
|
||||
grouped_procs: HashMap<String, Proc>,
|
||||
processes: HashMap<u32, process::Process>,
|
||||
@ -62,6 +65,8 @@ impl ProcWidget<'_> {
|
||||
sorting: ProcSorting::Cpu,
|
||||
sort_direction: SortDirection::Down,
|
||||
|
||||
cpu_count: cpu::cpu_count(),
|
||||
|
||||
procs: Vec::new(),
|
||||
grouped_procs: HashMap::new(),
|
||||
processes: HashMap::new(),
|
||||
@ -84,6 +89,7 @@ impl UpdatableWidget for ProcWidget<'_> {
|
||||
});
|
||||
|
||||
let mut to_remove = Vec::new();
|
||||
let cpu_count = self.cpu_count as f32;
|
||||
|
||||
self.procs = self
|
||||
.processes
|
||||
@ -95,7 +101,7 @@ impl UpdatableWidget for ProcWidget<'_> {
|
||||
num: process.pid(),
|
||||
name: name.to_string(),
|
||||
commandline: process.cmdline()?.unwrap_or_else(|| format!("[{}]", name)),
|
||||
cpu: process.cpu_percent()?,
|
||||
cpu: process.cpu_percent()? / cpu_count,
|
||||
mem: process.memory_percent()?,
|
||||
})
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user