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
impl StatsHistory
Sourcepub fn new(descriptors: Vec<StatDescriptor>, capacity: Option<usize>) -> Self
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.
Sourcepub fn push_entries(&mut self, stats: &[StatEntry], tick: u64)
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.
Sourcepub fn descriptors(&self) -> &[StatDescriptor]
pub fn descriptors(&self) -> &[StatDescriptor]
Series the history records.
Sourcepub fn capacity(&self) -> Option<usize>
pub fn capacity(&self) -> Option<usize>
Maximum number of samples the history keeps, or None while it keeps every sample.
Sourcepub fn write_count(&self) -> usize
pub fn write_count(&self) -> usize
Total number of writes, including those that wrapped.
Sourcepub fn get(&self, col: usize, j: usize) -> Option<(f64, u64)>
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.
Sourcepub fn tick(&self, j: usize) -> Option<u64>
pub fn tick(&self, j: usize) -> Option<u64>
Returns the tick at logical index j, where 0 is the oldest visible entry.
Sourcepub fn entries(&self, j: usize) -> Option<Vec<StatEntry>>
pub fn entries(&self, j: usize) -> Option<Vec<StatEntry>>
Returns the sample at logical index j, in the shape that crate::export::StatsWriter accepts.
Sourcepub fn heap_bytes(&self) -> usize
pub fn heap_bytes(&self) -> usize
Heap memory held by the history, in bytes.