iai_callgrind_runner::runner::metrics

Struct Metrics

source
pub struct Metrics<K: Hash + Eq>(pub IndexMap<K, u64>);
Available on crate feature runner only.
Expand description

The Metrics backed by an indexmap::IndexMap

The insertion order is preserved.

Tuple Fields§

§0: IndexMap<K, u64>

Implementations§

source§

impl Metrics<EventKind>

source

pub fn make_summary(&mut self) -> Result<()>

Calculate and add derived summary events (i.e. estimated cycles) in-place

Additional calls to this function will overwrite the metrics for derived summary events.

§Errors

If the necessary cache simulation events (when running callgrind with –cache-sim) were not present.

source

pub fn is_summarized(&self) -> bool

Return true if costs are already summarized

This method just probes for EventKind::EstimatedCycles to detect the summarized state.

source

pub fn can_summarize(&self) -> bool

Return true if costs can be summarized

This method probes for EventKind::I1mr which is present if callgrind was run with the cache simulation (--cache-sim=yes) enabled.

source§

impl<K: Hash + Eq + Display + Clone> Metrics<K>

source

pub fn empty() -> Self

Return empty Metrics

source

pub fn with_metric_kinds<T>(kinds: T) -> Self
where T: IntoIterator<Item = (K, u64)>,

source

pub fn add_iter_str<I, T>(&mut self, iter: T) -> Result<()>
where I: AsRef<str>, T: IntoIterator<Item = I>,

Add metrics from an iterator over strings

Adding metrics stops as soon as there are no more keys in this Metrics or no more values in the iterator. This property is especially important for the metrics from the callgrind output files. From the documentation of the callgrind format:

If a cost line specifies less event counts than given in the “events” line, the rest is assumed to be zero.

§Errors

If one of the strings in the iterator is not parsable as u64

source

pub fn add(&mut self, other: &Self)

Sum this Metric with another Metric

Do not use this method if both Metrics can differ in their keys order.

source

pub fn metric_by_index(&self, index: usize) -> Option<u64>

Return the metric of the kind at index (of insertion order) if present

This operation is O(1)

source

pub fn metric_by_kind(&self, kind: &K) -> Option<u64>

Return the metric of the kind if present

This operation is O(1)

source

pub fn try_metric_by_kind(&self, kind: &K) -> Result<u64>

Return the metric kind or an error

§Errors

If the metric kind is not present

source

pub fn metric_kinds(&self) -> Vec<K>

source

pub fn metric_kinds_union<'a>(&'a self, other: &'a Self) -> IndexSet<&'a K>

Create the union set of the keys of this and another Metrics

The order of the keys is preserved. New keys from the other Metrics are appended in their original order.

source

pub fn iter(&self) -> Iter<'_, K, u64>

Return an iterator over the metrics in insertion order

source

pub fn is_empty(&self) -> bool

Return true if there are no metrics present

source

pub fn insert(&mut self, key: K, value: u64) -> Option<u64>

Insert a single metric

If an equivalent key already exists in the map: the key remains and retains in its place in the order, its corresponding value is updated with value, and the older value is returned inside Some(_).

If no equivalent key existed in the map: the new key-value pair is inserted, last in order, and None is returned.

source

pub fn insert_all(&mut self, entries: &[(K, u64)])

Insert all metrics

See also Metrics::insert

Trait Implementations§

source§

impl<K: Clone + Hash + Eq> Clone for Metrics<K>

source§

fn clone(&self) -> Metrics<K>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<K: Debug + Hash + Eq> Debug for Metrics<K>

source§

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

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

impl<'de, K> Deserialize<'de> for Metrics<K>
where K: Deserialize<'de> + Hash + Eq,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<I, K: Hash + Eq + From<I>> FromIterator<I> for Metrics<K>

source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = I>,

Creates a value from an iterator. Read more
source§

impl<'a, K: Hash + Eq + Display + Clone> IntoIterator for &'a Metrics<K>

source§

type Item = (&'a K, &'a u64)

The type of the elements being iterated over.
source§

type IntoIter = Iter<'a, K, u64>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K: Hash + Eq + JsonSchema> JsonSchema for Metrics<K>

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl<K: PartialEq + Hash + Eq> PartialEq for Metrics<K>

source§

fn eq(&self, other: &Metrics<K>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K> Serialize for Metrics<K>
where K: Serialize + Hash + Eq,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<&Metrics<EventKind>> for CacheSummary

source§

type Error = Error

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

fn try_from(value: &Metrics) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<K: Eq + Hash + Eq> Eq for Metrics<K>

source§

impl<K: Hash + Eq> StructuralPartialEq for Metrics<K>

Auto Trait Implementations§

§

impl<K> Freeze for Metrics<K>

§

impl<K> RefUnwindSafe for Metrics<K>
where K: RefUnwindSafe,

§

impl<K> Send for Metrics<K>
where K: Send,

§

impl<K> Sync for Metrics<K>
where K: Sync,

§

impl<K> Unpin for Metrics<K>
where K: Unpin,

§

impl<K> UnwindSafe for Metrics<K>
where K: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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

Checks if this value is equivalent to the given key. 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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

Checks if this value is equivalent to the given key. 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,