fn sample_frequency(samples: &[Duration]) -> Vec<(String, u64)> {
    let sample_count = samples.len();
    let mut count_by_duration: BTreeMap<u128, u64> = BTreeMap::new();
    for sample in samples {
        if sample.as_millis() > 0 {
            *count_by_duration.entry(sample.as_millis()).or_default() += 1;
        }
    }
    count_by_duration
        .iter()
        .map(|(ping, count)| {
            let ping = format!("{}", ping);
            let freq_pct = ((*count as f64 / sample_count as f64) * 100_f64) as u64;
            (ping, freq_pct)
        })
        .collect()
}
/// Return the frequency % grouped by sample duration.
Return the frequency % grouped by sample duration.
Return the frequency % grouped by sample duration .
fn sample_frequency(samples: &[Duration]) -> Vec<(String, u64)> {
    let sample_count = samples.len();
    let mut count_by_duration: BTreeMap<u128, u64> = BTreeMap::new();
    for sample in samples {
        if sample.as_millis() > 0 {
            *count_by_duration.entry(sample.as_millis()).or_default() += 1;
        }
    }
    count_by_duration
        .iter()
        .map(|(ping, count)| {
            let ping = format!("{}", ping);
            let freq_pct = ((*count as f64 / sample_count as f64) * 100_f64) as u64;
            (ping, freq_pct)
        })
        .collect()
}
fn sample_frequency ( samples : & [ Duration ] ) -> Vec < ( String , u64 ) > { let sample_count = samples . len ( ) ; let mut count_by_duration : BTreeMap < u128 , u64 > = BTreeMap :: new ( ) ; for sample in samples { if sample . as_millis ( ) > 0 { * count_by_duration . entry ( sample . as_millis ( ) ) . or_default ( ) += 1 ; } } count_by_duration . iter ( ) . map ( | ( ping , count ) | { let ping = format ! ( " " ping ) ; let freq_pct = ( ( * count as f64 / sample_count as f64 ) * 100_f64 ) as u64 ; ( ping , freq_pct ) } ) . collect ( ) }
Return the frequency % grouped by sample duration.
Return the frequency % grouped by sample duration .
samples
&[Duration]