heim-cpu 0.0.4

Cross-platform CPU information
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use heim_common::{Error, Result};

fn clock_ticks() -> Result<f64> {
    let result = unsafe { libc::sysconf(libc::_SC_CLK_TCK) };

    if result > 0 {
        Ok(result as f64)
    } else {
        Err(Error::last_os_error())
    }
}

lazy_static::lazy_static! {
    // Time units in USER_HZ or Jiffies
    pub static ref CLOCK_TICKS: f64 = clock_ticks()
        .expect("Unable to determine CPU number of ticks per second");
}