pub struct MemoryMetrics {
pub algorithm_type: AlgorithmType,
pub current_usage_bytes: usize,
pub peak_usage_bytes: usize,
pub last_updated: Instant,
}
Expand description
Memory metrics for a single algorithm
Fields§
§algorithm_type: AlgorithmType
Algorithm this metric belongs to
current_usage_bytes: usize
Current memory usage in bytes
peak_usage_bytes: usize
Peak memory usage in bytes seen so far
last_updated: Instant
When this metric was last updated
Implementations§
Source§impl MemoryMetrics
impl MemoryMetrics
Sourcepub fn new(algorithm_type: AlgorithmType) -> Self
pub fn new(algorithm_type: AlgorithmType) -> Self
Create new memory metrics for an algorithm
Sourcepub fn is_stale(&self, threshold: Duration) -> bool
pub fn is_stale(&self, threshold: Duration) -> bool
Check if this metric is stale (hasn’t been updated recently)
Sourcepub fn format_current(&self) -> String
pub fn format_current(&self) -> String
Format current memory usage as human-readable string
Sourcepub fn format_peak(&self) -> String
pub fn format_peak(&self) -> String
Format peak memory usage as human-readable string
Sourcepub fn format_bytes(bytes: usize) -> String
pub fn format_bytes(bytes: usize) -> String
Format bytes into human-readable string
Sourcepub fn efficiency_ratio(&self) -> f64
pub fn efficiency_ratio(&self) -> f64
Get memory efficiency ratio (current / peak)
Sourcepub fn is_at_peak(&self) -> bool
pub fn is_at_peak(&self) -> bool
Check if memory usage is currently at peak
Trait Implementations§
Source§impl Clone for MemoryMetrics
impl Clone for MemoryMetrics
Source§fn clone(&self) -> MemoryMetrics
fn clone(&self) -> MemoryMetrics
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for MemoryMetrics
impl Debug for MemoryMetrics
Source§impl PartialEq for MemoryMetrics
impl PartialEq for MemoryMetrics
impl StructuralPartialEq for MemoryMetrics
Auto Trait Implementations§
impl Freeze for MemoryMetrics
impl RefUnwindSafe for MemoryMetrics
impl Send for MemoryMetrics
impl Sync for MemoryMetrics
impl Unpin for MemoryMetrics
impl UnwindSafe for MemoryMetrics
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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