remove some 'as' casts and unused returned timeval

This commit is contained in:
Francis Lalonde 2023-01-26 15:25:12 -05:00
parent 38c1315f31
commit 37c7d806ea
2 changed files with 4 additions and 7 deletions

View File

@ -230,10 +230,7 @@ impl Timer {
/// Obtain a opaque handle to the current time.
/// The handle is passed back to the stop() method to record a time interval.
/// This is actually a convenience method to the TimeHandle::now()
/// Beware, handles obtained here are not bound to this specific timer instance
/// _for now_ but might be in the future for safety.
/// If you require safe multi-timer handles, get them through TimeType::now()
/// Caveat: Handles obtained are not bound to this specific timer instance (but should be)
pub fn start(&self) -> TimeHandle {
TimeHandle::now()
}
@ -242,9 +239,9 @@ impl Timer {
/// This call can be performed multiple times using the same handle,
/// reporting distinct time intervals each time.
/// Returns the microsecond interval value that was recorded.
pub fn stop(&self, start_time: TimeHandle) -> MetricValue {
pub fn stop(&self, start_time: TimeHandle) {
let elapsed_us = start_time.elapsed_us();
self.interval_us(elapsed_us) as isize
self.interval_us(elapsed_us);
}
/// Record the time taken to execute the provided closure

View File

@ -40,7 +40,7 @@ fn pcg32_random() -> u32 {
/// none | 0.0 | 0xFFFFFFFF | 0%
pub fn to_int_rate(float_rate: f64) -> u32 {
assert!((0.0..=1.0).contains(&float_rate));
((1.0 - float_rate) * f64::from(::std::u32::MAX)) as u32
((1.0 - float_rate) * f64::from(u32::MAX)) as u32
}
/// randomly select samples based on an int rate