Created
May 19, 2023 10:24
-
-
Save 0xdeafbeef/4071a1128af5a92d1a5ebdcace847ddc to your computer and use it in GitHub Desktop.
print hist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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