pub async fn cpu_usage(&self) -> ProcessResult<CpuUsage> {
        let (cpu_time, cpu_count) = future::try_join(
            self.cpu_time(),
            heim_cpu::logical_count().map_err(Into::into),
        )
        .await?;

        Ok(CpuUsage {
            cpu_count,
            cpu_time,
            at: Instant::now(),
        })
    }
/// Returns CPU usage measurement.
///
/// Returned [`CpuUsage`] struct represents instantaneous CPU usage and does not represent
/// any reasonable value by itself.
/// It is suggested to wait for a while with help of any async timer
/// (for accuracy recommended delay should be at least 100 ms),
/// call this method once again and subtract former [`CpuUsage`] from the new one.
///
/// Same to any *nix system, calculated CPU usage might exceed 100 %
/// if the process is running multiple threads on different CPU cores.
///
/// ## Example
///
/// ```rust
/// # use std::time::Duration;
/// # use heim_common::units::ratio;
/// # use heim_process::{self as process, Process, ProcessResult};
/// #
/// # #[heim_derive::main]
/// # async fn main() -> ProcessResult<()> {
/// let process = process::current().await?;
/// let measurement_1 = process.cpu_usage().await?;
/// // Or any other async timer at your choice
/// futures_timer::Delay::new(Duration::from_millis(100)).await;
/// let measurement_2 = process.cpu_usage().await?;
///
/// println!("CPU usage: {} %", (measurement_2 - measurement_1).get::<ratio::percent>());
/// # Ok(())
/// # }
/// ```
///
/// [`CpuUsage`]: ./struct.CpuUsage.html
Returns CPU usage measurement.
Returned [`CpuUsage`] struct represents instantaneous CPU usage and does not represent
any reasonable value by itself.
It is suggested to wait for a while with help of any async timer
(for accuracy recommended delay should be at least 100 ms),
call this method once again and subtract former [`CpuUsage`] from the new one.

Same to any *nix system, calculated CPU usage might exceed 100 %
if the process is running multiple threads on different CPU cores.
Returns CPU usage measurement . Returned [ ` CpuUsage ` ] struct represents instantaneous CPU usage and does not represent any reasonable value by itself . It is suggested to wait for a while with help of any async timer ( for accuracy recommended delay should be at least 100 ms ) call this method once again and subtract former [ ` CpuUsage ` ] from the new one . Same to any * nix system calculated CPU usage might exceed 100 % if the process is running multiple threads on different CPU cores .
pub async fn cpu_usage(&self) -> ProcessResult<CpuUsage> {
        let (cpu_time, cpu_count) = future::try_join(
            self.cpu_time(),
            heim_cpu::logical_count().map_err(Into::into),
        )
        .await?;
        Ok(CpuUsage {
            cpu_count,
            cpu_time,
            at: Instant::now(),
        })
    }
pub async fn cpu_usage ( & self ) -> ProcessResult < CpuUsage > { let ( cpu_time , cpu_count ) = future :: try_join ( self . cpu_time ( ) , heim_cpu :: logical_count ( ) . map_err ( Into :: into ) , ) . await ? ; Ok ( CpuUsage { cpu_count , cpu_time , at : Instant :: now ( ) , } ) }
Returns CPU usage measurement.
Returns CPU usage measurement .
&self
&self
example
None
use std::time::duration;
None
use heim_common::units::ratio;
None
use heim_process::{self as process, process, processresult};
None
#[heim_derive::main]
None
async fn main() -> processresult<()> {
let process = process::current().await?;
let measurement_1 = process.cpu_usage().await?;
Or any other async timer at your choice
futures_timer::Delay::new(Duration::from_millis(100)).await;
let measurement_2 = process.cpu_usage().await?.


let process = process :: current () . await? ; let measurement_1 = process . cpu_usage () . await? ; Or any other async timer at your choice futures_timer :: Delay :: new ( Duration :: from_millis ( 100 )) . await ; let measurement_2 = process . cpu_usage () . await? .
ok(())
None
}
None