procfs_core

Struct CpuTime

source
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:

  1. 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.

  2. 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.

  3. 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

source

pub fn user_ms(&self) -> u64

Milliseconds spent in user mode

source

pub fn user_duration(&self) -> Duration

Time spent in user mode

source

pub fn nice_ms(&self) -> u64

Milliseconds spent in user mode with low priority (nice)

source

pub fn nice_duration(&self) -> Duration

Time spent in user mode with low priority (nice)

source

pub fn system_ms(&self) -> u64

Milliseconds spent in system mode

source

pub fn system_duration(&self) -> Duration

Time spent in system mode

source

pub fn idle_ms(&self) -> u64

Milliseconds spent in the idle state

source

pub fn idle_duration(&self) -> Duration

Time spent in the idle state

source

pub fn iowait_ms(&self) -> Option<u64>

Milliseconds spent waiting for I/O to complete

source

pub fn iowait_duration(&self) -> Option<Duration>

Time spent waiting for I/O to complete

source

pub fn irq_ms(&self) -> Option<u64>

Milliseconds spent servicing interrupts

source

pub fn irq_duration(&self) -> Option<Duration>

Time spent servicing interrupts

source

pub fn softirq_ms(&self) -> Option<u64>

Milliseconds spent servicing softirqs

source

pub fn softirq_duration(&self) -> Option<Duration>

Time spent servicing softirqs

source

pub fn steal_ms(&self) -> Option<u64>

Milliseconds of stolen time

source

pub fn steal_duration(&self) -> Option<Duration>

Amount of stolen time

source

pub fn guest_ms(&self) -> Option<u64>

Milliseconds spent running a virtual CPU for guest operating systems under control of the linux kernel

source

pub fn guest_duration(&self) -> Option<Duration>

Time spent running a virtual CPU for guest operating systems under control of the linux kernel

source

pub fn guest_nice_ms(&self) -> Option<u64>

Milliseconds spent running a niced guest

source

pub fn guest_nice_duration(&self) -> Option<Duration>

Time spent running a niced guest

Trait Implementations§

source§

impl Clone for CpuTime

source§

fn clone(&self) -> CpuTime

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CpuTime

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for CpuTime

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for CpuTime

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,