Struct AccArray

Source
pub struct AccArray<const S: bool, T: TraceValue, C: TraceCount, const N: usize>
where TDesc<S>: TArch,
{ /* private fields */ }
Expand description

An AccArray can be used to accumulate the times taken to execute different branches of code, from a common start point. Each branch is allocated a different index into the AccArray. It can also count the entries.

The AccArray is generic on whether to use the CPU-specific architcture timer implementation, the value to accumulate times in (e.g. u64), the value to use to count occurrences (e.g. u32), and the number of trace points in the vec

The ‘start’ method is called first; when a branch completed it invokes the ‘acc_n’ method with its index, and the delta time since the start is added to that start’s accumulator.

Invoking the ‘acc_n’ method does not update the ‘start’ time, and it is quite sensible to issue multiple ‘acc’ invocations (with different index values) for a given ‘start’ invocation.

The ‘acc_n_restart’ method, though, performs the same accumulation and it does update the ‘start’ time; this can be used to accumulate elapsed time between stages.

An AccArray can be generated for any N, for an accumulator value of (), u8, u16, u32, u64, u128 and usize, and for a counter value of (), u8, u16, u32, u64, usize. If a value of () is used then the count or delta accumulator are effectively always 0.

Implementations§

Source§

impl<const S: bool, T, C, const N: usize> AccArray<S, T, C, N>
where TDesc<S>: TArch, T: TraceValue, C: TraceCount,

Source

pub fn clear(&mut self)

Clear the timer and accumulated values

Source

pub fn start(&mut self)

Start the underlying timer

Source

pub fn acc_n(&mut self, index: usize)

Add the ticks on exit to a specific region

Source

pub fn acc_n_restart(&mut self, index: usize)

Add the ticks on exit to a specific region

Source

pub fn accs(&self) -> &[T; N]

Return the accumulated values

Source

pub fn cnts(&self) -> &[C; N]

Return the accumulated counts

Trait Implementations§

Source§

impl<const S: bool, T: Debug + TraceValue, C: Debug + TraceCount, const N: usize> Debug for AccArray<S, T, C, N>
where TDesc<S>: TArch,

Source§

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

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

impl<const S: bool, T, C, const N: usize> Default for AccArray<S, T, C, N>

Source§

fn default() -> Self

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

impl<const S: bool, T, C, const N: usize> Display for AccArray<S, T, C, N>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const S: bool, T, C, const N: usize> !Freeze for AccArray<S, T, C, N>

§

impl<const S: bool, T, C, const N: usize> !RefUnwindSafe for AccArray<S, T, C, N>

§

impl<const S: bool, T, C, const N: usize> !Send for AccArray<S, T, C, N>

§

impl<const S: bool, T, C, const N: usize> !Sync for AccArray<S, T, C, N>

§

impl<const S: bool, T, C, const N: usize> !Unpin for AccArray<S, T, C, N>

§

impl<const S: bool, T, C, const N: usize> !UnwindSafe for AccArray<S, T, C, N>

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.