CpuLoad

Struct CpuLoad 

Source
pub struct CpuLoad { /* private fields */ }
Expand description

CPU Load Monitor CPU 负载监控器

Implementations§

Source§

impl CpuLoad

Source

pub fn new() -> Self

Create monitor with default 1s interval 使用默认 1 秒间隔创建监控器

Source

pub fn init(interval: Duration) -> Self

Create monitor and start background sampling task 创建监控器并启动后台采样任务

Source

pub fn idlest(&self) -> usize

Get the index of the idlest CPU core (Round-Robin with periodic re-sort) 获取最空闲的 CPU 核心索引(轮询 + 周期性重排序)

Source

pub fn global(&self) -> u8

Get the current global CPU load (0-100) 获取当前全局 CPU 负载 (0-100)

Source

pub fn core(&self, idx: usize) -> Option<u8>

Get the load of a specific core (0-100) 获取指定核心的负载 (0-100)

Source

pub fn len(&self) -> usize

Get the number of CPU cores 获取 CPU 核心数

Source

pub fn is_empty(&self) -> bool

Check if no cores (always false in practice) 检查是否无核心(实际上总是 false)

Trait Implementations§

Source§

impl Default for CpuLoad

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for CpuLoad

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Generator<CpuLoad> for __StaticInitGeneratorFor_CPU_LOAD

Available on (Linux or Android or FreeBSD or DragonFly BSD or NetBSD or OpenBSD or Solaris or illumos or Emscripten or Haiku or L4Re or Fuchsia or Redox or target_os=vxworks), or Windows, or (macOS or iOS) only.
Source§

impl<'a> IntoIterator for &'a CpuLoad

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = CpuLoadIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more