Struct quanta::Clock[][src]

pub struct Clock { /* fields omitted */ }
Expand description

Unified clock for taking measurements.

Implementations

Creates a new clock with the optimal reference and source clocks.

Support for TSC, etc, are checked at the time of creation, not compile-time.

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.

Gets the current time, scaled to reference time.

This method is the spiritual equivalent of std::time::Instant::now. It is guaranteed to return a monotonically increasing value between calls to the same Clock instance.

Returns an Instant.

Gets the underlying time from the fastest available clock source.

As the clock source may or may not be the TSC, value is not guaranteed to be in nanoseconds or to be monotonic. Value can be scaled to reference time by calling either scaled or delta.

If you need maximum accuracy in your measurements, consider using start and end.

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.

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.

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.

Returns an Instant.

Calculates the delta between two measurements, and scales to reference time.

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.

Gets the most recent current time, scaled to reference time.

This method provides ultra-low-overhead access to a slightly-delayed version of the current time. Instead of querying the underlying source clock directly, a shared, global value is read directly without the need to scale to reference time.

The upkeep thread must be started in order to update the time. You can read the documentation for [Builder] for more information on starting the upkeep thread, as well as the details of the “current time” mechanism.

If the upkeep thread has not been started, the return value will be 0.

Returns an Instant.

Updates the recent current time.

Most callers should use the existing [Builder] machinery for spawning a background thread to handle upkeep, rather than calling [upkeep] directly.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. 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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.