fn print_histogram<W: Write>(w: &mut W, values: &[f64]) -> std::io::Result<()> {
    // TODO: Use better algorithm.
    // Is there any common and good algorithm?
    if values.is_empty() {
        return Ok(());
    }
    let lines = 11;
    let data = crate::histogram::histogram(values, lines);

    let max_bar = data.iter().map(|t| t.1).max().unwrap();
    let str_len_max = max_bar.to_string().len();

    for (label, b) in data.iter() {
        let indent = str_len_max - b.to_string().len();
        write!(w, "  {:.3} [{}]{} |", label, b, " ".repeat(indent))?;
        bar(w, *b as f64 / max_bar as f64)?;
        writeln!(w)?;
    }
    Ok(())
}
/// Print histogram of series of f64 data.
/// This is used to print histogram of response time.
Print histogram of series of f64 data.
This is used to print histogram of response time.
Print histogram of series of f64 data . This is used to print histogram of response time .
fn print_histogram<W: Write>(w: &mut W, values: &[f64]) -> std::io::Result<()> {
    // TODO: Use better algorithm.
    // Is there any common and good algorithm?
    if values.is_empty() {
        return Ok(());
    }
    let lines = 11;
    let data = crate::histogram::histogram(values, lines);
    let max_bar = data.iter().map(|t| t.1).max().unwrap();
    let str_len_max = max_bar.to_string().len();
    for (label, b) in data.iter() {
        let indent = str_len_max - b.to_string().len();
        write!(w, "  {:.3} [{}]{} |", label, b, " ".repeat(indent))?;
        bar(w, *b as f64 / max_bar as f64)?;
        writeln!(w)?;
    }
    Ok(())
}
fn print_histogram < W : Write > ( w : & mut W , values : & [ f64 ] ) -> std :: io :: Result < ( ) > { // TODO: Use better algorithm. // Is there any common and good algorithm? if values . is_empty ( ) { return Ok ( ( ) ) ; } let lines = 11 ; let data = crate :: histogram :: histogram ( values , lines ) ; let max_bar = data . iter ( ) . map ( | t | t . 1 ) . max ( ) . unwrap ( ) ; let str_len_max = max_bar . to_string ( ) . len ( ) ; for ( label , b ) in data . iter ( ) { let indent = str_len_max - b . to_string ( ) . len ( ) ; write ! ( w " " label b " " repeat ( indent ) ) ? ; bar ( w , * b as f64 / max_bar as f64 ) ? ; writeln ! ( w ) ? ; } Ok ( ( ) ) }
Print histogram of series of f64 data.
Print histogram of series of f64 data .
w
&mut W
values
&[f64]