pub struct CpuTime {
pub user: u64,
pub nice: u64,
pub system: u64,
pub idle: u64,
pub iowait: Option<u64>,
pub irq: Option<u64>,
pub softirq: Option<u64>,
pub steal: Option<u64>,
pub guest: Option<u64>,
pub guest_nice: Option<u64>,
/* private fields */
}
Expand description
The amount of time, measured in ticks, the CPU has been in specific states
These fields are measured in ticks because the underlying data from the kernel is measured in ticks. The number of ticks per second is generally 100 on most systems.
To convert this value to seconds, you can divide by the tps. There are also convenience methods that you can use too.
Fields§
§user: u64
Ticks spent in user mode
nice: u64
Ticks spent in user mode with low priority (nice)
system: u64
Ticks spent in system mode
idle: u64
Ticks spent in the idle state
iowait: Option<u64>
Ticks waiting for I/O to complete
This value is not reliable, for the following reasons:
-
The CPU will not wait for I/O to complete; iowait is the time that a task is waiting for I/O to complete. When a CPU goes into idle state for outstanding task I/O, another task will be scheduled on this CPU.
-
On a multi-core CPU, this task waiting for I/O to complete is not running on any CPU, so the iowait for each CPU is difficult to calculate.
-
The value in this field may decrease in certain conditions.
(Since Linux 2.5.41)
irq: Option<u64>
Ticks servicing interrupts
(Since Linux 2.6.0)
softirq: Option<u64>
Ticks servicing softirqs
(Since Linux 2.6.0)
steal: Option<u64>
Ticks of stolen time.
Stolen time is the time spent in other operating systems when running in a virtualized environment.
(Since Linux 2.6.11)
guest: Option<u64>
Ticks spent running a virtual CPU for guest operating systems under control of the linux kernel
(Since Linux 2.6.24)
guest_nice: Option<u64>
Ticks spent running a niced guest
(Since Linux 2.6.33)
Implementations§
source§impl CpuTime
impl CpuTime
sourcepub fn user_duration(&self) -> Duration
pub fn user_duration(&self) -> Duration
Time spent in user mode
sourcepub fn nice_duration(&self) -> Duration
pub fn nice_duration(&self) -> Duration
Time spent in user mode with low priority (nice)
sourcepub fn system_duration(&self) -> Duration
pub fn system_duration(&self) -> Duration
Time spent in system mode
sourcepub fn idle_duration(&self) -> Duration
pub fn idle_duration(&self) -> Duration
Time spent in the idle state
sourcepub fn iowait_duration(&self) -> Option<Duration>
pub fn iowait_duration(&self) -> Option<Duration>
Time spent waiting for I/O to complete
sourcepub fn irq_duration(&self) -> Option<Duration>
pub fn irq_duration(&self) -> Option<Duration>
Time spent servicing interrupts
sourcepub fn softirq_ms(&self) -> Option<u64>
pub fn softirq_ms(&self) -> Option<u64>
Milliseconds spent servicing softirqs
sourcepub fn softirq_duration(&self) -> Option<Duration>
pub fn softirq_duration(&self) -> Option<Duration>
Time spent servicing softirqs
sourcepub fn steal_duration(&self) -> Option<Duration>
pub fn steal_duration(&self) -> Option<Duration>
Amount of stolen time
sourcepub fn guest_ms(&self) -> Option<u64>
pub fn guest_ms(&self) -> Option<u64>
Milliseconds spent running a virtual CPU for guest operating systems under control of the linux kernel
sourcepub fn guest_duration(&self) -> Option<Duration>
pub fn guest_duration(&self) -> Option<Duration>
Time spent running a virtual CPU for guest operating systems under control of the linux kernel
sourcepub fn guest_nice_ms(&self) -> Option<u64>
pub fn guest_nice_ms(&self) -> Option<u64>
Milliseconds spent running a niced guest
sourcepub fn guest_nice_duration(&self) -> Option<Duration>
pub fn guest_nice_duration(&self) -> Option<Duration>
Time spent running a niced guest
Trait Implementations§
source§impl<'de> Deserialize<'de> for CpuTime
impl<'de> Deserialize<'de> for CpuTime
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for CpuTime
impl RefUnwindSafe for CpuTime
impl Send for CpuTime
impl Sync for CpuTime
impl Unpin for CpuTime
impl UnwindSafe for CpuTime
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)