mprober_lib/cpu/
cpu_time.rs

1#[derive(Default, Debug, Clone, Copy)]
2pub struct CPUTime {
3    pub non_idle: u64,
4    pub idle:     u64,
5}
6
7impl CPUTime {
8    /// Get the total CPU time.
9    ///
10    /// ```rust
11    /// use mprober_lib::cpu;
12    ///
13    /// let average_cpu_stat = cpu::get_average_cpu_stat().unwrap();
14    /// let cpu_time = average_cpu_stat.compute_cpu_time();
15    /// let total_cpu_time = cpu_time.get_total_time();
16    ///
17    /// println!("{total_cpu_time}");
18    /// ```
19    #[inline]
20    pub fn get_total_time(self) -> u64 {
21        self.idle + self.non_idle
22    }
23}