[−][src]Struct perf_event::Counts
A collection of counts from a Group
of counters.
This is the type returned by calling read
on a Group
.
You can index it with a reference to a specific Counter
:
let counts = group.read()?; println!("cycles / instructions: {} / {} ({:.2} cpi)", counts[&cycles], counts[&insns], (counts[&cycles] as f64 / counts[&insns] as f64));
Or you can iterate over the results it contains:
for (id, value) in &counts { println!("Counter id {} has value {}", id, value); }
The id
values produced by this iteration are internal identifiers assigned
by the kernel. You can use the Counter::id
method to find a
specific counter's id.
Methods
impl Counts
[src]
pub fn get(&self, member: &Counter) -> Option<&u64>
[src]
Return the value recorded for member
in self
, or None
if member
is not present.
If you know that member
is in the group, you can simply index:
let cycles = counts[&cycle_counter];
ⓘImportant traits for CountsIter<'c>pub fn iter(&self) -> CountsIter
[src]
Return an iterator over the counts in self
.
for (id, value) in &counts { println!("Counter id {} has value {}", id, value); }
Each item is a pair (id, &value)
, where id
is the number assigned to
the counter by the kernel (see Counter::id
), and value
is that
counter's value.
Trait Implementations
impl Debug for Counts
[src]
impl<'_> Index<&'_ Counter> for Counts
[src]
impl<'c> IntoIterator for &'c Counts
[src]
type Item = (u64, &'c u64)
The type of the elements being iterated over.
type IntoIter = CountsIter<'c>
Which kind of iterator are we turning this into?
ⓘImportant traits for CountsIter<'c>fn into_iter(self) -> CountsIter<'c>
[src]
Auto Trait Implementations
impl RefUnwindSafe for Counts
impl Send for Counts
impl Sync for Counts
impl Unpin for Counts
impl UnwindSafe for Counts
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,