LoopTimer

Struct LoopTimer 

Source
pub struct LoopTimer {
    pub start: Instant,
    pub end: Instant,
    pub time: Duration,
    pub target: Duration,
    pub count: u32,
}
Expand description

Wraps the variables necessary to keep track of loop timings.

Fields§

§start: Instant

The last start of the loop.

§end: Instant

The last end of the loop.

§time: Duration

The last time/duration of the loop.

§target: Duration

The intended time/duration of the loop.

§count: u32

How many iterations have been done.

Implementations§

Source§

impl LoopTimer

Source

pub fn new(target: Duration) -> Self

Creates a new looptimer with the given target loop duration.

Source

pub fn new_from(now: Instant, target: Duration) -> Self

Creates a new looptimer with the given target loop duration and a starting instant.

Source

pub fn reset_count(&mut self)

Resets the loop-counter.

Source

pub fn start(&mut self)

Begins the loop measurement.

Source

pub fn end(&mut self)

Finishes the loop measurement.

Source

pub fn length(&self) -> u128

Returns the length of the last loop iteration, in nanoseconds.

Auto Trait Implementations§

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, 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.