Skip to main content

Record

Struct Record 

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

The metrics reported by one trial, or merged over many.

Implementations§

Source§

impl Record

Source

pub fn new() -> Record

An empty record.

Source

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).

Source

pub fn trial(&self) -> u64

The index of the trial of the condition this record belongs to (0 when merged).

Source

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).

Source

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).

Source

pub fn values(&mut self, name: &str, vs: impl IntoIterator<Item = f64>)

Add several values to the mean name (see Record::value).

Source

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.

Source

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);
Source

pub fn dropped_iter(&self) -> impl Iterator<Item = (&String, u64)>

The metrics with dropped values and their counts, sorted by name.

Source

pub fn knows(&self, name: &str) -> bool

Whether name was recorded, as an estimate or only as dropped values.

Source

pub fn get(&self, name: &str) -> Option<&Estimate>

The estimate of name.

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &Estimate)>

The metrics, sorted by name.

Source

pub fn is_empty(&self) -> bool

Whether the record holds no metric.

Trait Implementations§

Source§

impl Clone for Record

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 Debug for Record

Source§

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

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

impl Default for Record

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Record

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 Record

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> 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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.