pub struct DeltaTimer<const S: bool>{ /* private fields */ }Expand description
A timer that uses the underlying CPU clock ticks to generate precise timings for short-term execution
This should not be expected to be correct in all cases; if a thread sleeps or is interrupted, for example by the kernel, for any reason, then the CPU timer value may not be useful; if the thread migrates to a different CPU core it may become invalid; etc
The usage model is to capture a ‘start’ time and a ‘stop’ time; the value method can then be used to retrieve the CPU ticks between the start and stop
let mut t = DeltaTimer::<true>::default();
t.start();
// do something!
t.stop();
println!("That took {} ticks", t.value());Implementations§
Source§impl<const S: bool> DeltaTimer<S>
impl<const S: bool> DeltaTimer<S>
Trait Implementations§
Source§impl<const S: bool> Clone for DeltaTimer<S>
impl<const S: bool> Clone for DeltaTimer<S>
Source§fn clone(&self) -> DeltaTimer<S>
fn clone(&self) -> DeltaTimer<S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const S: bool> Debug for DeltaTimer<S>
impl<const S: bool> Debug for DeltaTimer<S>
Source§impl<const S: bool> Default for DeltaTimer<S>
impl<const S: bool> Default for DeltaTimer<S>
Source§fn default() -> DeltaTimer<S>
fn default() -> DeltaTimer<S>
Returns the “default value” for a type. Read more
impl<const S: bool> Copy for DeltaTimer<S>
Auto Trait Implementations§
impl<const S: bool> !Freeze for DeltaTimer<S>
impl<const S: bool> !RefUnwindSafe for DeltaTimer<S>
impl<const S: bool> !Send for DeltaTimer<S>
impl<const S: bool> !Sync for DeltaTimer<S>
impl<const S: bool> !Unpin for DeltaTimer<S>
impl<const S: bool> !UnwindSafe for DeltaTimer<S>
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
Mutably borrows from an owned value. Read more