pub struct ComputeDispatchTimer {
pub elapsed_ns: Option<u64>,
}Expand description
Wall-clock timer for a single compute dispatch.
Usage:
use oxiphysics_gpu::compute::timestamp::ComputeDispatchTimer;
let start = ComputeDispatchTimer::start_cpu();
// ... do work ...
let timer = ComputeDispatchTimer::stop_cpu(start);
if let Some(ms) = timer.elapsed_ms() {
println!("dispatch took {ms:.3} ms");
}Fields§
§elapsed_ns: Option<u64>Elapsed time in nanoseconds, set after stop_cpu.
Implementations§
Source§impl ComputeDispatchTimer
impl ComputeDispatchTimer
Sourcepub fn start_cpu() -> Instant
pub fn start_cpu() -> Instant
Record the current instant as the start of a timed region.
Pass the returned Instant to stop_cpu when the
region ends.
Sourcepub fn stop_cpu(start: Instant) -> Self
pub fn stop_cpu(start: Instant) -> Self
Stop the timer and return a ComputeDispatchTimer with elapsed time.
Sourcepub fn elapsed_ms(&self) -> Option<f64>
pub fn elapsed_ms(&self) -> Option<f64>
Return elapsed time in milliseconds, or None if the timer was never stopped.
Sourcepub fn elapsed_us(&self) -> Option<f64>
pub fn elapsed_us(&self) -> Option<f64>
Return elapsed time in microseconds, or None if the timer was never stopped.
Sourcepub fn has_measurement(&self) -> bool
pub fn has_measurement(&self) -> bool
Return true if the timer has been stopped and holds a measurement.
Trait Implementations§
Source§impl Clone for ComputeDispatchTimer
impl Clone for ComputeDispatchTimer
Source§fn clone(&self) -> ComputeDispatchTimer
fn clone(&self) -> ComputeDispatchTimer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ComputeDispatchTimer
impl Debug for ComputeDispatchTimer
Source§impl Default for ComputeDispatchTimer
impl Default for ComputeDispatchTimer
Source§fn default() -> ComputeDispatchTimer
fn default() -> ComputeDispatchTimer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ComputeDispatchTimer
impl RefUnwindSafe for ComputeDispatchTimer
impl Send for ComputeDispatchTimer
impl Sync for ComputeDispatchTimer
impl Unpin for ComputeDispatchTimer
impl UnsafeUnpin for ComputeDispatchTimer
impl UnwindSafe for ComputeDispatchTimer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more