Struct GdsfCacheMetrics

Source
pub struct GdsfCacheMetrics {
    pub core: CoreCacheMetrics,
    pub global_age: f64,
    pub total_aging_events: u64,
    pub min_priority: f64,
    pub max_priority: f64,
    pub total_frequency: u64,
    pub total_item_size_processed: u64,
    pub small_items_cached: u64,
    pub large_items_cached: u64,
    pub size_based_evictions: u64,
    pub total_frequency_size_ratio: f64,
}
Expand description

GDSF-specific metrics (extends CoreCacheMetrics)

This struct contains metrics specific to the GDSF (Greedy Dual-Size Frequency) cache algorithm. GDSF combines frequency, size, and aging using the formula: Priority = (Frequency / Size) + Global_Age

Fields§

§core: CoreCacheMetrics

Core metrics common to all cache algorithms

§global_age: f64

Current global age value

§total_aging_events: u64

Total number of aging events (when global age is increased)

§min_priority: f64

Current minimum priority in the cache

§max_priority: f64

Current maximum priority in the cache

§total_frequency: u64

Total frequency of all items (cumulative)

§total_item_size_processed: u64

Total size of all items ever processed (for size-frequency analysis)

§small_items_cached: u64

Number of small items (below average size) that were cached

§large_items_cached: u64

Number of large items (above average size) that were cached

§size_based_evictions: u64

Total number of size-based evictions (items evicted due to poor size/frequency ratio)

§total_frequency_size_ratio: f64

Sum of all frequency/size ratios for efficiency analysis

Implementations§

Source§

impl GdsfCacheMetrics

Source

pub fn new(max_cache_size_bytes: u64) -> Self

Creates a new GdsfCacheMetrics instance with the specified maximum cache size

§Arguments
  • max_cache_size_bytes - The maximum allowed cache size in bytes
Source

pub fn record_aging_event(&mut self, new_global_age: f64)

Records an aging event (when global age is increased due to eviction)

§Arguments
  • new_global_age - The new global age value
Source

pub fn record_item_access(&mut self, frequency: u64, size: u64, priority: f64)

Records processing of an item (frequency increment and size tracking)

§Arguments
  • frequency - Current frequency of the item
  • size - Size of the item in bytes
  • priority - Calculated priority of the item
Source

pub fn record_item_cached(&mut self, size: u64, average_size: f64)

Records caching of an item with size classification

§Arguments
  • size - Size of the cached item in bytes
  • average_size - Current average item size for classification
Source

pub fn record_size_based_eviction(&mut self)

Records a size-based eviction

Source

pub fn average_frequency(&self) -> f64

Calculates the average frequency across all processed items

§Returns

Average frequency per item access, or 0.0 if no items processed

Source

pub fn average_item_size(&self) -> f64

Calculates the average size of processed items

§Returns

Average item size in bytes, or 0.0 if no items processed

Source

pub fn average_frequency_size_ratio(&self) -> f64

Calculates the average frequency-to-size ratio

§Returns

Average frequency/size ratio, or 0.0 if no items processed

Source

pub fn priority_range(&self) -> f64

Calculates the priority range (max - min)

§Returns

The range of priorities currently in the cache

Source

pub fn size_distribution_balance(&self) -> f64

Calculates size distribution balance (small vs large items)

§Returns

Ratio of small items to total cached items, or 0.0 if no items cached

Source

pub fn size_eviction_efficiency(&self) -> f64

Calculates size-based eviction efficiency

§Returns

Ratio of size-based evictions to total evictions

Source

pub fn to_btreemap(&self) -> BTreeMap<String, f64>

Converts GDSF metrics to a BTreeMap for reporting

This method returns all metrics relevant to the GDSF cache algorithm, including both core metrics and GDSF-specific size-frequency metrics.

Uses BTreeMap to ensure consistent, deterministic ordering of metrics.

§Returns

A BTreeMap containing all GDSF cache metrics as key-value pairs

Trait Implementations§

Source§

impl CacheMetrics for GdsfCacheMetrics

Source§

fn metrics(&self) -> BTreeMap<String, f64>

Returns all GDSF cache metrics as key-value pairs in deterministic order

§Returns

A BTreeMap containing all metrics tracked by this GDSF cache instance

Source§

fn algorithm_name(&self) -> &'static str

Returns the algorithm name for this cache implementation

§Returns

“GDSF” - identifying this as a Greedy Dual-Size Frequency cache

Source§

impl Clone for GdsfCacheMetrics

Source§

fn clone(&self) -> GdsfCacheMetrics

Returns a duplicate 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 GdsfCacheMetrics

Source§

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

Formats the value using the given formatter. 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.