Trait CacheMetrics

Source
pub trait CacheMetrics {
    // Required methods
    fn metrics(&self) -> BTreeMap<String, f64>;
    fn algorithm_name(&self) -> &'static str;
}
Expand description

Trait that all cache algorithms must implement for metrics reporting

This trait provides a uniform interface for retrieving metrics from any cache implementation. It allows the simulation system to collect and compare metrics across different cache algorithms.

The trait uses BTreeMap to ensure deterministic ordering of metrics, which is essential for reproducible benchmarks and consistent test results.

Required Methods§

Source

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

Returns all metrics as key-value pairs in deterministic order

The returned BTreeMap contains all relevant metrics for the cache algorithm, including both core metrics and any algorithm-specific metrics. Keys are sorted alphabetically for consistent output.

§Returns

A BTreeMap where keys are metric names and values are metric values as f64

Source

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

Algorithm name for identification

§Returns

A static string identifying the cache algorithm (e.g., “LRU”, “LFU”, “SLRU”)

Implementors§