pub fn create_hgrm(hist: &Histogram, w: &mut ::std::io::Write) -> Result<(), io::Error> { w.write_all( format!( "{:>12} {:>14} {:>10} {:>14}\n\n", "Value", "Percentile", "TotalCount", "1/(1-Percentile)" ).as_ref(), )?; let mut sum = 0; let sigfig: usize = hist.sigfig() as usize; for v in hist.iter_quantiles(5 /* ticks per half */) { sum += v.count_since_last_iteration(); println!("{} {} ", v.count_at_value(), v.count_since_last_iteration()); if v.quantile() < 1.0 { let other = 1f64 / (1f64 - v.percentile() / 100f64); w.write_all( format!( "{:12.*} {:2.12} {:10} {:14.2}\n", sigfig, v.value() as f64, v.quantile(), sum, other ).as_ref(), )?; } else { w.write_all( format!( "{:12.*} {:2.12} {:10}\n", sigfig, v.value() as f64, v.quantile(), sum ).as_ref(), )?; } } let mean = hist.mean(); // / output_value_unit_scaling_ratio as f64; let stdev = hist.stdev(); // hist.significant_value_digits w.write_all( format!( "#[Mean = {:12.2}, StdDeviation = {:12.2}]\n", mean, stdev ).as_ref(), )?; let max = hist.max(); // / output_value_unit_scaling_ratio; let total = hist.count(); w.write_all( format!( "#[Max = {:12.2}, TotalCount = {:12.2}]\n", max, total ).as_ref(), )?; w.write_all( format!( "#[Buckets = {:12}, SubBuckets = {:12}]\n", hist.buckets(), hist.len(), ).as_ref(), )?; // out_file.write(b'#[Buckets = %12d, SubBuckets = %12d]\n' % ( // self.bucket_count, self.sub_bucket_count)) Ok(()) }