pub struct ResourceMonitor { /* private fields */ }Expand description
Resource monitoring
Implementations§
Source§impl ResourceMonitor
impl ResourceMonitor
Sourcepub fn start_monitoring(&mut self)
pub fn start_monitoring(&mut self)
Discard any samples collected so far and begin a fresh window.
This crate takes no measurements of its own: reading CPU and memory
counters requires platform-specific system interfaces, and the project’s
pure-Rust policy rules out the FFI they need. Until 0.3.2 this method
had an empty body with the comment “Implementation would use system
monitoring libraries”, so stop_monitoring reported a summary over an
empty sample set as though it had measured something. Feed measurements
in with Self::record_sample; the summary then describes real data or
honestly reports none.
Sourcepub fn record_sample(
&mut self,
cpu_percent: f64,
memory_mb: usize,
gpu_memory_mb: Option<usize>,
)
pub fn record_sample( &mut self, cpu_percent: f64, memory_mb: usize, gpu_memory_mb: Option<usize>, )
Record one observation. gpu_memory_mb is None when no GPU is in use.
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Number of samples recorded in the current window.
Sourcepub fn interval_seconds(&self) -> u64
pub fn interval_seconds(&self) -> u64
The sampling interval the monitor was configured with, in seconds.
Sourcepub fn stop_monitoring(&self) -> ResourceUsage
pub fn stop_monitoring(&self) -> ResourceUsage
Stop monitoring and return resource usage summary
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResourceMonitor
impl RefUnwindSafe for ResourceMonitor
impl Send for ResourceMonitor
impl Sync for ResourceMonitor
impl Unpin for ResourceMonitor
impl UnsafeUnpin for ResourceMonitor
impl UnwindSafe for ResourceMonitor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.