Struct devtimer::ComplexTimer

source ·
pub struct ComplexTimer { /* private fields */ }
Expand description

Complex Timer

A complex timer wraps around a map of timer names and their corresponding SimpleTimer instances.

Implementations§

source§

impl ComplexTimer

source

pub fn new() -> Self

Return a new ComplexTimer instance

source

pub fn create_timer( &mut self, timer_name: &'static str ) -> Result<(), &'static str>

Create a new timer tag. If the timer tag already exists, then this function returns an error.

source

pub fn start_timer( &mut self, timer_name: &'static str ) -> Result<(), &'static str>

Start a timer with tag timer_name. If this timer tag doesn’t exist, then it returns an error

source

pub fn stop_timer( &mut self, timer_name: &'static str ) -> Result<(), &'static str>

Stop a timer with tag timer_name. If this timer tag doesn’t exist, then it returns an error

source

pub fn time_in_secs(&self, timer_name: &'static str) -> Option<u64>

Get the time in seconds for a timer with tag timer_name

source

pub fn time_in_millis(&self, timer_name: &'static str) -> Option<u128>

Get the time in milliseconds for a timer with tag timer_name

source

pub fn time_in_micros(&self, timer_name: &'static str) -> Option<u128>

Get the time in microseconds for a timer with tag timer_name

source

pub fn time_in_nanos(&self, timer_name: &'static str) -> Option<u128>

Get the time in nanoseconds for a timer with tag timer_name

source

pub fn delete_timer( &mut self, timer_name: &'static str ) -> Result<(), &'static str>

Delete a timer with tag timer_name

source

pub fn clear_timers(&mut self)

Delete all set timers

source

pub fn print_results(&self)

Print all results in the following format:

timerx - 120 ns
timery - 1233 ns
...
source

pub fn iter(&self) -> Iter<'_, &'static str, SimpleTimer>

Returns an iterator of timer tags and the corresponding SimpleTimer instances

Example
use devtimer::DevTime;
fn main() {
    let mut dt = DevTime::new_complex();
    for (name, timer) in dt.iter() {
        println!("Timer: {} took {} ns", name, timer.time_in_nanos().unwrap());
    }
}

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.