pub struct ProcessInfo {
pub pid: i32,
pub ppid: i32,
pub curr_proc: ProcessTask,
pub curr_io: Option<Io>,
pub prev_io: Option<Io>,
pub curr_stat: Option<Stat>,
pub prev_stat: Option<Stat>,
pub curr_status: Option<Status>,
pub interval: Duration,
pub cwd: PathBuf,
}
Fields§
§pid: i32
§ppid: i32
§curr_proc: ProcessTask
§curr_io: Option<Io>
§prev_io: Option<Io>
§curr_stat: Option<Stat>
§prev_stat: Option<Stat>
§curr_status: Option<Status>
§interval: Duration
§cwd: PathBuf
Implementations§
Source§impl ProcessInfo
impl ProcessInfo
Sourcepub fn pid(&self) -> i32
pub fn pid(&self) -> i32
PID of process
Examples found in repository?
examples/sys_demo.rs (line 18)
1fn main() {
2 #[cfg(any(
3 target_os = "android",
4 target_os = "linux",
5 target_os = "macos",
6 target_os = "windows"
7 ))]
8 {
9 let cores = std::thread::available_parallelism()
10 .map(|p| p.get())
11 .unwrap_or(1);
12 for run in 1..=10 {
13 for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
14 if proc.cpu_usage() > 0.00001 {
15 println!(
16 "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
17 run,
18 proc.pid(),
19 proc.name(),
20 proc.status(),
21 proc.cpu_usage() / cores as f64,
22 proc.mem_size() / (1024 * 1024),
23 proc.virtual_size() / (1024 * 1024),
24 cores,
25 )
26 }
27 }
28 std::thread::sleep(std::time::Duration::from_millis(1000));
29 }
30 }
31}
Sourcepub fn name(&self) -> String
pub fn name(&self) -> String
Name of command
Examples found in repository?
examples/sys_demo.rs (line 19)
1fn main() {
2 #[cfg(any(
3 target_os = "android",
4 target_os = "linux",
5 target_os = "macos",
6 target_os = "windows"
7 ))]
8 {
9 let cores = std::thread::available_parallelism()
10 .map(|p| p.get())
11 .unwrap_or(1);
12 for run in 1..=10 {
13 for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
14 if proc.cpu_usage() > 0.00001 {
15 println!(
16 "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
17 run,
18 proc.pid(),
19 proc.name(),
20 proc.status(),
21 proc.cpu_usage() / cores as f64,
22 proc.mem_size() / (1024 * 1024),
23 proc.virtual_size() / (1024 * 1024),
24 cores,
25 )
26 }
27 }
28 std::thread::sleep(std::time::Duration::from_millis(1000));
29 }
30 }
31}
Sourcepub fn command(&self) -> String
pub fn command(&self) -> String
Full name of command, with arguments
WARNING: As this does no escaping, this function is lossy. It’s OK-ish for display purposes but nothing else.
pub fn cwd(&self) -> String
Sourcepub fn status(&self) -> String
pub fn status(&self) -> String
Get the status of the process
Examples found in repository?
examples/sys_demo.rs (line 20)
1fn main() {
2 #[cfg(any(
3 target_os = "android",
4 target_os = "linux",
5 target_os = "macos",
6 target_os = "windows"
7 ))]
8 {
9 let cores = std::thread::available_parallelism()
10 .map(|p| p.get())
11 .unwrap_or(1);
12 for run in 1..=10 {
13 for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
14 if proc.cpu_usage() > 0.00001 {
15 println!(
16 "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
17 run,
18 proc.pid(),
19 proc.name(),
20 proc.status(),
21 proc.cpu_usage() / cores as f64,
22 proc.mem_size() / (1024 * 1024),
23 proc.virtual_size() / (1024 * 1024),
24 cores,
25 )
26 }
27 }
28 std::thread::sleep(std::time::Duration::from_millis(1000));
29 }
30 }
31}
Sourcepub fn cpu_usage(&self) -> f64
pub fn cpu_usage(&self) -> f64
CPU usage as a percent of total
Examples found in repository?
examples/sys_demo.rs (line 14)
1fn main() {
2 #[cfg(any(
3 target_os = "android",
4 target_os = "linux",
5 target_os = "macos",
6 target_os = "windows"
7 ))]
8 {
9 let cores = std::thread::available_parallelism()
10 .map(|p| p.get())
11 .unwrap_or(1);
12 for run in 1..=10 {
13 for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
14 if proc.cpu_usage() > 0.00001 {
15 println!(
16 "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
17 run,
18 proc.pid(),
19 proc.name(),
20 proc.status(),
21 proc.cpu_usage() / cores as f64,
22 proc.mem_size() / (1024 * 1024),
23 proc.virtual_size() / (1024 * 1024),
24 cores,
25 )
26 }
27 }
28 std::thread::sleep(std::time::Duration::from_millis(1000));
29 }
30 }
31}
Sourcepub fn mem_size(&self) -> u64
pub fn mem_size(&self) -> u64
Memory size in number of bytes
Examples found in repository?
examples/sys_demo.rs (line 22)
1fn main() {
2 #[cfg(any(
3 target_os = "android",
4 target_os = "linux",
5 target_os = "macos",
6 target_os = "windows"
7 ))]
8 {
9 let cores = std::thread::available_parallelism()
10 .map(|p| p.get())
11 .unwrap_or(1);
12 for run in 1..=10 {
13 for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
14 if proc.cpu_usage() > 0.00001 {
15 println!(
16 "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
17 run,
18 proc.pid(),
19 proc.name(),
20 proc.status(),
21 proc.cpu_usage() / cores as f64,
22 proc.mem_size() / (1024 * 1024),
23 proc.virtual_size() / (1024 * 1024),
24 cores,
25 )
26 }
27 }
28 std::thread::sleep(std::time::Duration::from_millis(1000));
29 }
30 }
31}
Sourcepub fn virtual_size(&self) -> u64
pub fn virtual_size(&self) -> u64
Virtual memory size in bytes
Examples found in repository?
examples/sys_demo.rs (line 23)
1fn main() {
2 #[cfg(any(
3 target_os = "android",
4 target_os = "linux",
5 target_os = "macos",
6 target_os = "windows"
7 ))]
8 {
9 let cores = std::thread::available_parallelism()
10 .map(|p| p.get())
11 .unwrap_or(1);
12 for run in 1..=10 {
13 for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
14 if proc.cpu_usage() > 0.00001 {
15 println!(
16 "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
17 run,
18 proc.pid(),
19 proc.name(),
20 proc.status(),
21 proc.cpu_usage() / cores as f64,
22 proc.mem_size() / (1024 * 1024),
23 proc.virtual_size() / (1024 * 1024),
24 cores,
25 )
26 }
27 }
28 std::thread::sleep(std::time::Duration::from_millis(1000));
29 }
30 }
31}
Auto Trait Implementations§
impl Freeze for ProcessInfo
impl RefUnwindSafe for ProcessInfo
impl Send for ProcessInfo
impl Sync for ProcessInfo
impl Unpin for ProcessInfo
impl UnwindSafe for ProcessInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more