[−][src]Struct mprober_lib::cpu::CPUStat
Fields
user: u64nice: u64system: u64idle: u64iowait: u64irq: u64softirq: u64steal: u64guest: u64guest_nice: u64Implementations
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,
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.
fn to_owned(&self) -> T[src]
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.
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>,