pub struct Record { /* private fields */ }Expand description
The metrics reported by one trial, or merged over many.
Implementations§
Source§impl Record
impl Record
Sourcepub fn for_trial(trial: u64) -> Record
pub fn for_trial(trial: u64) -> Record
An empty record of trial trial of its condition (the runner numbers the
trials; blocks that save or label a trial read it).
Sourcepub fn trial(&self) -> u64
pub fn trial(&self) -> u64
The index of the trial of the condition this record belongs to (0 when merged).
Sourcepub fn errors(&mut self, name: &str, errors: u64, total: u64)
pub fn errors(&mut self, name: &str, errors: u64, total: u64)
Add errors errors among total events to the error rate name.
If name is already a mean, the addition is dropped and counted
(Record::dropped).
Sourcepub fn value(&mut self, name: &str, v: f64)
pub fn value(&mut self, name: &str, v: f64)
Add a value to the mean name.
A non-finite value, or a value for a metric that is already an error rate, is
dropped and counted (Record::dropped).
Sourcepub fn values(&mut self, name: &str, vs: impl IntoIterator<Item = f64>)
pub fn values(&mut self, name: &str, vs: impl IntoIterator<Item = f64>)
Add several values to the mean name (see Record::value).
Sourcepub fn merge(&mut self, o: &Record)
pub fn merge(&mut self, o: &Record)
Merge another record: metrics of the same name and kind are combined, the drop counts are added. A metric of the other kind is dropped and counted: as many values as it holds for a mean, one for a rate.
Sourcepub fn dropped(&self, name: &str) -> u64
pub fn dropped(&self, name: &str) -> u64
The number of values of name dropped: non-finite, or of the other kind of
metric (0 if none).
§Examples
use comnum_sim::scenario::Record;
let mut rec = Record::new();
rec.value("snr_db", 12.0);
rec.value("snr_db", f64::INFINITY); // an error-free trial
rec.errors("snr_db", 1, 10); // the wrong kind
assert_eq!(rec.get("snr_db").unwrap().count(), 1);
assert_eq!(rec.dropped("snr_db"), 2);Sourcepub fn dropped_iter(&self) -> impl Iterator<Item = (&String, u64)>
pub fn dropped_iter(&self) -> impl Iterator<Item = (&String, u64)>
The metrics with dropped values and their counts, sorted by name.
Trait Implementations§
impl StructuralPartialEq for Record
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnsafeUnpin for Record
impl UnwindSafe for Record
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more