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
impl ComplexTimer
sourcepub fn create_timer(
&mut self,
timer_name: &'static str
) -> Result<(), &'static str>
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.
sourcepub fn start_timer(
&mut self,
timer_name: &'static str
) -> Result<(), &'static str>
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
sourcepub fn stop_timer(
&mut self,
timer_name: &'static str
) -> Result<(), &'static str>
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
sourcepub fn time_in_secs(&self, timer_name: &'static str) -> Option<u64>
pub fn time_in_secs(&self, timer_name: &'static str) -> Option<u64>
Get the time in seconds for a timer with tag timer_name
sourcepub fn time_in_millis(&self, timer_name: &'static str) -> Option<u128>
pub fn time_in_millis(&self, timer_name: &'static str) -> Option<u128>
Get the time in milliseconds for a timer with tag timer_name
sourcepub fn time_in_micros(&self, timer_name: &'static str) -> Option<u128>
pub fn time_in_micros(&self, timer_name: &'static str) -> Option<u128>
Get the time in microseconds for a timer with tag timer_name
sourcepub fn time_in_nanos(&self, timer_name: &'static str) -> Option<u128>
pub fn time_in_nanos(&self, timer_name: &'static str) -> Option<u128>
Get the time in nanoseconds for a timer with tag timer_name
sourcepub fn delete_timer(
&mut self,
timer_name: &'static str
) -> Result<(), &'static str>
pub fn delete_timer( &mut self, timer_name: &'static str ) -> Result<(), &'static str>
Delete a timer with tag timer_name
sourcepub fn clear_timers(&mut self)
pub fn clear_timers(&mut self)
Delete all set timers
sourcepub fn print_results(&self)
pub fn print_results(&self)
Print all results in the following format:
timerx - 120 ns
timery - 1233 ns
...
sourcepub fn iter(&self) -> Iter<'_, &'static str, SimpleTimer>
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());
}
}