Struct mprober_lib::cpu::CPUStat [−][src]
pub struct CPUStat { pub user: u64, pub nice: u64, pub system: u64, pub idle: u64, pub iowait: u64, pub irq: u64, pub softirq: u64, pub steal: u64, pub guest: u64, pub guest_nice: u64, }
Fields
user: u64
nice: u64
system: u64
idle: u64
iowait: u64
irq: u64
softirq: u64
steal: u64
guest: u64
guest_nice: u64
Implementations
impl CPUStat
[src]
pub fn compute_cpu_time(&self) -> CPUTime
[src]
Add all idle time and non-idle time respectively.
extern crate mprober_lib; use mprober_lib::cpu; let average_cpu_stat = cpu::get_average_cpu_stat().unwrap(); let cpu_time = average_cpu_stat.compute_cpu_time(); println!("{:#?}", cpu_time);
pub fn compute_cpu_utilization_in_percentage(
&self,
cpu_stat_after_this: &CPUStat
) -> f64
[src]
&self,
cpu_stat_after_this: &CPUStat
) -> f64
Compute CPU utilization in percentage between two CPUStat
instances at different time. If it returns 1.0
, means 100%
.
extern crate mprober_lib; use std::thread::sleep; use std::time::Duration; use mprober_lib::cpu; let pre_average_cpu_stat = cpu::get_average_cpu_stat().unwrap(); sleep(Duration::from_millis(100)); let average_cpu_stat = cpu::get_average_cpu_stat().unwrap(); let cpu_percentage = pre_average_cpu_stat.compute_cpu_utilization_in_percentage(&average_cpu_stat); println!("{:.2}%", cpu_percentage * 100.0);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CPUStat
impl Send for CPUStat
impl Sync for CPUStat
impl Unpin for CPUStat
impl UnwindSafe for CPUStat
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,