pub struct FragmentationMetrics {
pub total_free_bytes: usize,
pub largest_free_block: usize,
pub free_block_count: u32,
}Expand description
Measures memory fragmentation of free space.
Fields§
§total_free_bytes: usizeTotal free bytes across all free blocks.
largest_free_block: usizeSize of the largest contiguous free block.
free_block_count: u32Number of separate free blocks.
Implementations§
Source§impl FragmentationMetrics
impl FragmentationMetrics
Sourcepub fn new(total_free: usize, largest_block: usize, block_count: u32) -> Self
pub fn new(total_free: usize, largest_block: usize, block_count: u32) -> Self
Creates a new FragmentationMetrics.
Sourcepub fn fragmentation_ratio(&self) -> f64
pub fn fragmentation_ratio(&self) -> f64
Computes the fragmentation ratio.
Returns 1.0 - (largest_free_block / total_free_bytes).
A value of 0.0 means no fragmentation (single contiguous block).
A value near 1.0 means high fragmentation.
Returns 0.0 if total_free_bytes is zero.
Sourcepub fn average_free_block_size(&self) -> usize
pub fn average_free_block_size(&self) -> usize
Returns the average free block size, or 0 if there are no free blocks.
Trait Implementations§
Source§impl Clone for FragmentationMetrics
impl Clone for FragmentationMetrics
Source§fn clone(&self) -> FragmentationMetrics
fn clone(&self) -> FragmentationMetrics
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 FragmentationMetrics
impl Debug for FragmentationMetrics
Source§impl Default for FragmentationMetrics
impl Default for FragmentationMetrics
Source§fn default() -> FragmentationMetrics
fn default() -> FragmentationMetrics
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FragmentationMetrics
impl RefUnwindSafe for FragmentationMetrics
impl Send for FragmentationMetrics
impl Sync for FragmentationMetrics
impl Unpin for FragmentationMetrics
impl UnsafeUnpin for FragmentationMetrics
impl UnwindSafe for FragmentationMetrics
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