Skip to main content

Stats

Struct Stats 

Source
pub struct Stats {
    pub hits: u64,
    pub promotions: u64,
    pub misses: u64,
    pub inserts: u64,
    pub updates: u64,
    pub flips: u64,
    pub entries: usize,
    pub peak_entries: usize,
    pub cap: usize,
}
Expand description

What a cache has done since it was created or reset: see LruCache::stats.

Lookups are get, get_mut and the two get_or_insert_with methods; each is a hit, a promotion or a miss. put is not a lookup: it counts as an insert or an update.

Fields§

§hits: u64

Lookups found in the current generation.

§promotions: u64

Lookups found in the previous generation (moved back into the current one). These are hits too, but they survived only because that generation had not been dropped yet: many of them mean the keys in use slightly outnumber cap.

§misses: u64

Lookups that found nothing.

§inserts: u64

New keys added, by put or by a read-through’s miss.

§updates: u64

put calls on a key already in the cache.

§flips: u64

Flips: how often the current generation filled up.

§entries: usize

Entries held now, in both generations (up to 2 * cap).

§peak_entries: usize

The most entries ever held: the memory the workload actually needed.

§cap: usize

The cache’s capacity.

Implementations§

Source§

impl Stats

Source

pub fn lookups(&self) -> u64

Hits, promotions and misses together.

Source

pub fn hit_ratio(&self) -> f64

The share of lookups that found their key (hits and promotions), from 0.0 to 1.0; 0.0 before any lookup.

Source

pub fn flips_per_1000_lookups(&self) -> f64

Flips per 1000 lookups. At most 1000 / cap (every lookup a new key).

Source

pub fn sizing(&self) -> Sizing

A verdict on the capacity, from these counts. See Sizing for what each means and what to do.

Trait Implementations§

Source§

impl Clone for Stats

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Stats

Source§

impl Debug for Stats

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Stats

Source§

impl PartialEq for Stats

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Stats

Auto Trait Implementations§

§

impl Freeze for Stats

§

impl RefUnwindSafe for Stats

§

impl Send for Stats

§

impl Sync for Stats

§

impl Unpin for Stats

§

impl UnsafeUnpin for Stats

§

impl UnwindSafe for Stats

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.