pub struct ProfileDuration { /* private fields */ }Expand description
Result from profiling between two measurements. This can either be a duration or a future that resolves to a duration.
The future resolves to None when the window turned out to carry no
measurement, which a backend can only discover once the device has answered.
That absence is not a zero: zero is the fastest duration there is, so a
caller comparing candidates would let an unmeasured one win every comparison
it enters.
Implementations§
Source§impl ProfileDuration
impl ProfileDuration
Sourcepub fn timing_method(&self) -> TimingMethod
pub fn timing_method(&self) -> TimingMethod
The method used to measure the execution time.
Sourcepub fn new(
future: Pin<Box<dyn Future<Output = Option<ProfileTicks>> + Send>>,
method: TimingMethod,
) -> ProfileDuration
pub fn new( future: Pin<Box<dyn Future<Output = Option<ProfileTicks>> + Send>>, method: TimingMethod, ) -> ProfileDuration
Create a new ProfileDuration from a future that resolves to a duration.
Sourcepub fn new_system_time(start: Instant, end: Instant) -> ProfileDuration
pub fn new_system_time(start: Instant, end: Instant) -> ProfileDuration
Create a new ProfileDuration straight from a duration.
Sourcepub fn new_device_time(
future: impl Future<Output = ProfileTicks> + Send + 'static,
) -> ProfileDuration
pub fn new_device_time( future: impl Future<Output = ProfileTicks> + Send + 'static, ) -> ProfileDuration
Create a new ProfileDuration from a future that resolves to a duration.
Sourcepub fn new_device_time_maybe(
future: impl Future<Output = Option<ProfileTicks>> + Send + 'static,
) -> ProfileDuration
pub fn new_device_time_maybe( future: impl Future<Output = Option<ProfileTicks>> + Send + 'static, ) -> ProfileDuration
Create a new ProfileDuration from a future that may resolve to no
measurement at all, for a backend that only learns the window carried
none once the device has answered.
Sourcepub fn into_future(
self,
) -> Pin<Box<dyn Future<Output = Option<ProfileTicks>> + Send>>
pub fn into_future( self, ) -> Pin<Box<dyn Future<Output = Option<ProfileTicks>> + Send>>
Retrieve the future that resolves the profile.
Sourcepub async fn resolve(self) -> Option<ProfileTicks>
pub async fn resolve(self) -> Option<ProfileTicks>
Resolve the actual duration of the profile, possibly by waiting for the future to complete.
None when the window carried no measurement. See the type’s docs for
why that is not reported as a zero duration.