pub fn iter_segment_times_at_percentile(
        &self,
        percentile: f64,
    ) -> impl Iterator<Item = TimeSpan> + '_ {
        self.all_weighted_segment_times
            .iter()
            .map(move |weighted_segment_times| {
                let found_index = weighted_segment_times
                    .binary_search_by(|&(w, _)| w.partial_cmp(&percentile).unwrap());

                match found_index {
                    // The percentile perfectly matched a segment time
                    Ok(index) => weighted_segment_times[index].1,
                    // The percentile didn't perfectly match, interpolate instead
                    Err(right_index) => {
                        // Saturate both left and right index at the bounds of the
                        // array. Both could go out of bounds.
                        let left_index = right_index.saturating_sub(1);
                        // This assumes len can never be 0. This only works out
                        // for us because we truncate all the empty segments away.
                        let right_index = right_index.min(weighted_segment_times.len() - 1);

                        if left_index == right_index {
                            weighted_segment_times[left_index].1
                        } else {
                            let right = weighted_segment_times[right_index];
                            let left = weighted_segment_times[left_index];

                            interpolate(percentile, left, right)
                        }
                    }
                }
            })
    }
/// This function returns an iterator that iterates over each segment and
/// yields their segment times for the percentile specified. A percentile of
/// 0 yields the fastest times, while a percentile of 1 yields the slowest
/// times.
This function returns an iterator that iterates over each segment and
yields their segment times for the percentile specified. A percentile of
0 yields the fastest times, while a percentile of 1 yields the slowest
times.
This function returns an iterator that iterates over each segment and yields their segment times for the percentile specified . A percentile of 0 yields the fastest times while a percentile of 1 yields the slowest times .
pub fn iter_segment_times_at_percentile(
        &self,
        percentile: f64,
    ) -> impl Iterator<Item = TimeSpan> + '_ {
        self.all_weighted_segment_times
            .iter()
            .map(move |weighted_segment_times| {
                let found_index = weighted_segment_times
                    .binary_search_by(|&(w, _)| w.partial_cmp(&percentile).unwrap());
                match found_index {
                    // The percentile perfectly matched a segment time
                    Ok(index) => weighted_segment_times[index].1,
                    // The percentile didn't perfectly match, interpolate instead
                    Err(right_index) => {
                        // Saturate both left and right index at the bounds of the
                        // array. Both could go out of bounds.
                        let left_index = right_index.saturating_sub(1);
                        // This assumes len can never be 0. This only works out
                        // for us because we truncate all the empty segments away.
                        let right_index = right_index.min(weighted_segment_times.len() - 1);
                        if left_index == right_index {
                            weighted_segment_times[left_index].1
                        } else {
                            let right = weighted_segment_times[right_index];
                            let left = weighted_segment_times[left_index];
                            interpolate(percentile, left, right)
                        }
                    }
                }
            })
    }
pub fn iter_segment_times_at_percentile ( & self , percentile : f64 , ) -> impl Iterator < Item = TimeSpan > + ' _ { self . all_weighted_segment_times . iter ( ) . map ( move | weighted_segment_times | { let found_index = weighted_segment_times . binary_search_by ( | & ( w , _ ) | w . partial_cmp ( & percentile ) . unwrap ( ) ) ; match found_index { // The percentile perfectly matched a segment time Ok ( index ) => weighted_segment_times [ index ] . 1 , // The percentile didn't perfectly match, interpolate instead Err ( right_index ) => { // Saturate both left and right index at the bounds of the // array. Both could go out of bounds. let left_index = right_index . saturating_sub ( 1 ) ; // This assumes len can never be 0. This only works out // for us because we truncate all the empty segments away. let right_index = right_index . min ( weighted_segment_times . len ( ) - 1 ) ; if left_index == right_index { weighted_segment_times [ left_index ] . 1 } else { let right = weighted_segment_times [ right_index ] ; let left = weighted_segment_times [ left_index ] ; interpolate ( percentile , left , right ) } } } } ) }
This function returns an iterator that iterates over each segment and
yields their segment times for the percentile specified.
This function returns an iterator that iterates over each segment and yields their segment times for the percentile specified .
&self
percentile
f64
&self
percentile
f64