Skip to main content

StatsHistory

Struct StatsHistory 

Source
pub struct StatsHistory { /* private fields */ }
Expand description

Ring-buffer history of stat values, polled every snapshot.

The charts read one f64 per series per frame, so that is what a sample costs. A series that a scalar cannot round-trip keeps its full value alongside. An export then carries the same columns that the headless runner writes.

Implementations§

Source§

impl StatsHistory

Source

pub fn new(descriptors: Vec<StatDescriptor>, capacity: Option<usize>) -> Self

Creates an empty history of descriptors, keeping at most capacity samples, or every sample for None.

Source

pub fn push_entries(&mut self, stats: &[StatEntry], tick: u64)

Records one sample, replacing the newest entry if it has the same tick.

A publish repeats a tick when nothing stepped, as after an action or while a paused layout relaxes. The replacement keeps one entry per tick, holding the latest stats for it.

The first sample fixes which series keep a full value, the same way it fixes a CSV column layout. A series that changes kind later is a model bug, and crate::export::StatsWriter already reports it as a bug.

Source

pub fn descriptors(&self) -> &[StatDescriptor]

Series the history records.

Source

pub fn len(&self) -> usize

Number of entries stored, at most the capacity.

Source

pub fn is_empty(&self) -> bool

Returns whether no sample has been recorded.

Source

pub fn capacity(&self) -> Option<usize>

Maximum number of samples the history keeps, or None while it keeps every sample.

Source

pub fn write_count(&self) -> usize

Total number of writes, including those that wrapped.

Source

pub fn get(&self, col: usize, j: usize) -> Option<(f64, u64)>

Returns the value of series col and its tick at logical index j, where 0 is the oldest visible entry.

Source

pub fn tick(&self, j: usize) -> Option<u64>

Returns the tick at logical index j, where 0 is the oldest visible entry.

Source

pub fn entries(&self, j: usize) -> Option<Vec<StatEntry>>

Returns the sample at logical index j, in the shape that crate::export::StatsWriter accepts.

Source

pub fn heap_bytes(&self) -> usize

Heap memory held by the history, in bytes.

Source

pub fn resize(&mut self, new_capacity: Option<usize>)

Changes the capacity to new_capacity, keeping the most recent entries that fit.

Trait Implementations§

Source§

impl Debug for StatsHistory

Prints the series labels and the sample counts, not the samples.

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> 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, 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.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSync for T
where T: Sync,