[−][src]Struct quanta::Clock
Unified clock for taking measurements.
Methods
impl Clock
[src]
pub fn new() -> Clock
[src]
Creates a new clock with the optimal reference and source.
Both the reference clock and source clock are chosen at compile-time to be the fastest underlying clocks available. The source clock is calibrated against the reference clock if need be.
pub fn mock() -> (Clock, Arc<Mock>)
[src]
Creates a new clock that is mocked for controlling the underlying time.
Returns a Clock
instance and a handle to the underlying Mock
source so that the
caller can control the passage of time.
pub fn now(&self) -> u64
[src]
Gets the current time, scaled to reference time.
Value is in nanoseconds.
pub fn raw(&self) -> u64
[src]
Gets the underlying time from the source clock.
Value is not guaranteed to be in nanoseconds.
It requires conversion to reference time, however, via scaled
or delta
.
If you need maximum accuracy in your measurements, consider using start
and end
.
pub fn start(&self) -> u64
[src]
Gets the underlying time from the source clock, specific to starting an operation.
Value is not guaranteed to be in nanoseconds.
Provides the same functionality as raw
, but tries to ensure that no extra CPU
instructions end up executing after the measurement is taken. Since normal processors are
typically out-of-order, other operations that logically come before a call to this method
could be reordered to come after the measurement, thereby skewing the overall time
measured.
pub fn end(&self) -> u64
[src]
Gets the underlying time from the source clock, specific to ending an operation.
Value is not guaranteed to be in nanoseconds.
Provides the same functionality as raw
, but tries to ensure that no extra CPU
instructions end up executing before the measurement is taken. Since normal processors are
typically out-of-order, other operations that logically come after a call to this method
could be reordered to come before the measurement, thereby skewing the overall time
measured.
pub fn scaled(&self, value: u64) -> u64
[src]
Scales a raw measurement to reference time.
You must scale raw measurements to ensure your result is in nanoseconds. The raw measurement is not guaranteed to be in nanoseconds and may vary. It is only OK to avoid scaling raw measurements if you don't need actual nanoseconds.
Value is in nanoseconds.
pub fn delta(&self, start: u64, end: u64) -> u64
[src]
Calculates the delta between two measurements, and scales to reference time.
Value is in nanoseconds.
This method is slightly faster when you know you need the delta between two raw
measurements, or a start/end measurement, than using scaled
for both conversions.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,