pub struct Metrics<K: Hash + Eq>(pub IndexMap<K, u64>);
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>
impl Metrics<EventKind>
sourcepub fn make_summary(&mut self) -> Result<()>
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.
sourcepub fn is_summarized(&self) -> bool
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.
sourcepub fn can_summarize(&self) -> bool
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>
impl<K: Hash + Eq + Display + Clone> Metrics<K>
pub fn with_metric_kinds<T>(kinds: T) -> Selfwhere
T: IntoIterator<Item = (K, u64)>,
sourcepub fn add_iter_str<I, T>(&mut self, iter: T) -> Result<()>
pub fn add_iter_str<I, T>(&mut self, iter: T) -> Result<()>
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
sourcepub fn add(&mut self, other: &Self)
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.
sourcepub fn metric_by_index(&self, index: usize) -> Option<u64>
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)
sourcepub fn metric_by_kind(&self, kind: &K) -> Option<u64>
pub fn metric_by_kind(&self, kind: &K) -> Option<u64>
Return the metric of the kind
if present
This operation is O(1)
sourcepub fn try_metric_by_kind(&self, kind: &K) -> Result<u64>
pub fn try_metric_by_kind(&self, kind: &K) -> Result<u64>
pub fn metric_kinds(&self) -> Vec<K>
sourcepub fn metric_kinds_union<'a>(&'a self, other: &'a Self) -> IndexSet<&'a K>
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.
sourcepub fn insert(&mut self, key: K, value: u64) -> Option<u64>
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.
sourcepub fn insert_all(&mut self, entries: &[(K, u64)])
pub fn insert_all(&mut self, entries: &[(K, u64)])
Insert all metrics
See also Metrics::insert
Trait Implementations§
source§impl<'de, K> Deserialize<'de> for Metrics<K>
impl<'de, K> Deserialize<'de> for Metrics<K>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<I, K: Hash + Eq + From<I>> FromIterator<I> for Metrics<K>
impl<I, K: Hash + Eq + From<I>> FromIterator<I> for Metrics<K>
source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = I>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = I>,
source§impl<K: Hash + Eq + JsonSchema> JsonSchema for Metrics<K>
impl<K: Hash + Eq + JsonSchema> JsonSchema for Metrics<K>
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreimpl<K: Eq + Hash + Eq> Eq for Metrics<K>
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> 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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