pub async fn usage() -> Result<CpuUsage> {
    let (cpu_time, cpu_count) =
        future::try_join(time(), 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_common::prelude::*;
/// # use heim_cpu::usage;
/// #
/// # #[heim_derive::main]
/// # async fn main() -> Result<()> {
/// let measurement_1 = usage().await?;
/// // Or any other async timer at your choice
/// futures_timer::Delay::new(Duration::from_millis(100)).await;
/// let measurement_2 = 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 usage() -> Result<CpuUsage> {
    let (cpu_time, cpu_count) =
        future::try_join(time(), logical_count().map_err(Into::into)).await?;
    Ok(CpuUsage {
        cpu_count,
        cpu_time,
        at: Instant::now(),
    })
}
pub async fn usage ( ) -> Result < CpuUsage > { let ( cpu_time , cpu_count ) = future :: try_join ( time ( ) , logical_count ( ) . map_err ( Into :: into ) ) . await ? ; Ok ( CpuUsage { cpu_count , cpu_time , at : Instant :: now ( ) , } ) }
Returns CPU usage measurement.
Returns CPU usage measurement .
example
None
use std::time::duration;
None
use heim_common::units::ratio;
None
use heim_common::prelude::*;
None
use heim_cpu::usage;
None
#[heim_derive::main]
None
async fn main() -> result<()> {
let measurement_1 = usage().await?;
Or any other async timer at your choice
futures_timer::Delay::new(Duration::from_millis(100)).await;
let measurement_2 = usage().await?.


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