pub struct MetricsSnapshot { /* private fields */ }Expand description
A read-only, point-in-time representation of Metrics.
Created via Metrics::snapshot or [Metrics::into].
Implementations§
Source§impl MetricsSnapshot
impl MetricsSnapshot
Sourcepub fn hit_count(&self) -> u64
pub fn hit_count(&self) -> u64
Returns the total number of hits recorded at the time of the snapshot.
Sourcepub fn miss_count(&self) -> u64
pub fn miss_count(&self) -> u64
Returns the total number of misses recorded at the time of the snapshot.
Sourcepub fn eviction_count(&self) -> u64
pub fn eviction_count(&self) -> u64
Returns the total number of evictions recorded at the time of the snapshot.
Sourcepub fn miss_rate(&self) -> f64
pub fn miss_rate(&self) -> f64
Calculates the miss rate ($misses / (hits + misses)$).
Returns 0.0 if no activity was recorded to prevent division-by-zero errors.
Sourcepub fn hit_rate(&self) -> f64
pub fn hit_rate(&self) -> f64
Calculates the hit rate ($hits / (hits + misses)$).
Returns 0.0 if no activity was recorded.
Sourcepub fn latency(&self, percentile: LatencyPercentile) -> u64
pub fn latency(&self, percentile: LatencyPercentile) -> u64
Returns the latency value at a specific percentile using a type-safe enum.
This is the preferred method for monitoring cache performance, as it explicitly categorizes measurements into median, tail, and extreme tail latencies.
§Performance
The lookup is $O(1)$ relative to the number of samples in the histogram.