pub fn find_percentile_for_time(&self, offset: TimeSpan, time_to_find: TimeSpan) -> f64 {
        let (mut perc_min, mut perc_max) = (0.0, 1.0);

        // Try to find the correct percentile
        for _ in 0..TRIES {
            let percentile = (perc_max + perc_min) / 2.0;

            let sum = self
                .iter_segment_times_at_percentile(percentile)
                .fold(offset, |sum, segment_time| sum + segment_time);

            // Binary search the correct percentile
            match sum.partial_cmp(&time_to_find) {
                Some(Ordering::Equal) => return percentile,
                Some(Ordering::Less) => perc_min = percentile,
                Some(Ordering::Greater) => perc_max = percentile,
                None => {}
            }
        }

        (perc_max + perc_min) / 2.0
    }
/// Searches the curve for the final run time specified and returns the
/// percentile the time can be found at. The percentile is always within the
/// range 0..1. If the time specified cannot be found, the percentile
/// saturates at one of those boundaries.
Searches the curve for the final run time specified and returns the
percentile the time can be found at. The percentile is always within the
range 0..1. If the time specified cannot be found, the percentile
saturates at one of those boundaries.
Searches the curve for the final run time specified and returns the percentile the time can be found at . The percentile is always within the range 0 .. 1 . If the time specified cannot be found the percentile saturates at one of those boundaries .
pub fn find_percentile_for_time(&self, offset: TimeSpan, time_to_find: TimeSpan) -> f64 {
        let (mut perc_min, mut perc_max) = (0.0, 1.0);
        // Try to find the correct percentile
        for _ in 0..TRIES {
            let percentile = (perc_max + perc_min) / 2.0;
            let sum = self
                .iter_segment_times_at_percentile(percentile)
                .fold(offset, |sum, segment_time| sum + segment_time);
            // Binary search the correct percentile
            match sum.partial_cmp(&time_to_find) {
                Some(Ordering::Equal) => return percentile,
                Some(Ordering::Less) => perc_min = percentile,
                Some(Ordering::Greater) => perc_max = percentile,
                None => {}
            }
        }
        (perc_max + perc_min) / 2.0
    }
pub fn find_percentile_for_time ( & self , offset : TimeSpan , time_to_find : TimeSpan ) -> f64 { let ( mut perc_min , mut perc_max ) = ( 0.0 , 1.0 ) ; // Try to find the correct percentile for _ in 0 .. TRIES { let percentile = ( perc_max + perc_min ) / 2.0 ; let sum = self . iter_segment_times_at_percentile ( percentile ) . fold ( offset , | sum , segment_time | sum + segment_time ) ; // Binary search the correct percentile match sum . partial_cmp ( & time_to_find ) { Some ( Ordering :: Equal ) => return percentile , Some ( Ordering :: Less ) => perc_min = percentile , Some ( Ordering :: Greater ) => perc_max = percentile , None => { } } } ( perc_max + perc_min ) / 2.0 }
Searches the curve for the final run time specified and returns the
percentile the time can be found at.
Searches the curve for the final run time specified and returns the percentile the time can be found at .
&self
offset
TimeSpan
time_to_find
TimeSpan
&self
offset
TimeSpan
time_to_find
TimeSpan