Skip to main content

Timer

Struct Timer 

Source
pub struct Timer { /* private fields */ }
Expand description

One named measurement region.

A host timer brackets arbitrary host code. A device timer must be initialized against an runtime, then one Runtime::checkpoint_with_timer records the device timestamps around the submitted batch. The device path is single-flight: a timer cannot tag a new submission while its previous one is still pending.

Implementations§

Source§

impl Timer

Source

pub fn new(domain: TimerDomain, name: impl Into<String>) -> Self

Create a timer in domain named name.

Source

pub fn init(&mut self, runtime: &Runtime, name: impl Into<String>) -> Result<()>

Resolve Auto to Device and acquire this runtime’s device timestamp backend. A host timer needs no runtime and initialization is a no-op.

§Errors

Returns an error when the domain is Device and the runtime’s compute queue cannot provide timestamps.

Source

pub fn begin(&mut self) -> Result<()>

Begin a host-side region. Auto resolves to Host here.

§Errors

Returns an error when the timer resolves to Device — device regions are recorded by Runtime::checkpoint_with_timer — or when a previous host region is still running.

Source

pub fn end(&mut self) -> Result<()>

End the running host-side region.

§Errors

Returns an error without a matching Timer::begin.

Source

pub fn commit(&mut self, units: f64) -> Result<f64>

Commit the measured region in milliseconds and remember units for Timer::throughput. Never waits: a device timer requires its tagged submission to be complete.

§Errors
  • FailedPrecondition: no completed region exists (host timer without a finished begin/end, device timer without a tagged submission).
  • NotReady: the device submission is still pending.
  • Vulkan timestamp readback failures.
Source

pub const fn elapsed_milliseconds(&self) -> f64

Return the last committed region duration in milliseconds.

Source

pub const fn throughput(&self) -> f64

Return committed units per second, or 0.0 before a nonzero commit.

Source

pub const fn domain(&self) -> TimerDomain

Return the resolved or configured domain.

Source

pub const fn is_host(&self) -> bool

Return whether this timer measures host regions.

Source

pub const fn is_device(&self) -> bool

Return whether this timer measures device regions.

Source

pub fn is_initialized(&self) -> bool

Return whether this timer can measure in its current domain. A host timer is always initialized; a device timer requires Timer::init.

Source

pub fn is_pending(&self) -> bool

Return whether a measurement region is in flight: a running host region, or a device submission that has not completed.

Source

pub fn name(&self) -> &str

Return the configured timer name.

Auto Trait Implementations§

§

impl Forget for Timer

§

impl Freeze for Timer

§

impl Move for Timer

§

impl RefUnwindSafe for Timer

§

impl Send for Timer

§

impl Sync for Timer

§

impl Unpin for Timer

§

impl UnsafeUnpin for Timer

§

impl UnwindSafe for Timer

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.