#[repr(C)]
pub struct Clock { /* private fields */ }
Expand description

Utility type that measures the elapsed time.

Its provides the most precise time that the underlying OS can achieve (generally microseconds or nanoseconds). It also ensures monotonicity, which means that the returned time can never go backward, even if the system time is changed.

Usage example

let mut clock = Clock::start();
// ...
let time1 = clock.elapsed_time();
// ...
let time2 = clock.restart();

The Time value returned by the clock can then be converted to a number of seconds, milliseconds or even microseconds.

Implementations

Creates a new Clock and starts it automatically.

Gets the elapsed time.

This function returns the time elapsed since the last call to restart (or the construction of the instance if restart has not been called).

Restarts the clock.

This function puts the time counter back to zero. It also returns the time elapsed since the clock was started.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.