Skip to content

Instantly share code, notes, and snippets.

@0xdeafbeef
Created May 19, 2023 10:24
Show Gist options
  • Save 0xdeafbeef/4071a1128af5a92d1a5ebdcace847ddc to your computer and use it in GitHub Desktop.
Save 0xdeafbeef/4071a1128af5a92d1a5ebdcace847ddc to your computer and use it in GitHub Desktop.
print hist
fn print_hist(histogram: &Histogram) {
fn print_percentile(percentile: f64, hist: &Histogram) {
let bucket = hist.percentile(percentile).unwrap();
println!(
"Percentile {}% from {} to {} => {} count",
percentile,
bucket.low(),
bucket.high(),
bucket.count()
);
}
print_percentile(0.1, &histogram);
print_percentile(10.0, &histogram);
print_percentile(25.0, &histogram);
print_percentile(50.0, &histogram);
print_percentile(75.0, &histogram);
print_percentile(90.0, &histogram);
print_percentile(95.0, &histogram);
print_percentile(99.0, &histogram);
print_percentile(99.9, &histogram);
print_percentile(99.99, &histogram);
print_percentile(99.999, &histogram);
histogram.into_iter().for_each(|x| {
if x.count() > 0 {
println!("from {} to {} - {}", x.low(), x.high(), x.count());
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment