pub trait SampleQuantiles {
// Required method
fn quantiles(
&self,
quantiles: &[f64],
) -> Result<Option<QuantilesResult>, Error>;
// Provided method
fn quantile(&self, quantile: f64) -> Result<Option<QuantilesResult>, Error> { ... }
}Expand description
Trait for computing quantiles from histogram data.
Implemented for crate::Histogram and crate::SparseHistogram.
crate::AtomicHistogram does not implement this trait — use
AtomicHistogram::load() to get a
Histogram snapshot first.
§Examples
use histogram::{Histogram, SparseHistogram, SampleQuantiles};
let mut h = Histogram::new(7, 64).unwrap();
h.increment(100).unwrap();
// Works on both Histogram and SparseHistogram
fn show_p99(h: &impl SampleQuantiles) {
if let Ok(Some(result)) = h.quantile(0.99) {
let bucket = result.entries().values().next().unwrap();
println!("p99: {}-{}", bucket.start(), bucket.end());
}
}
show_p99(&h);
show_p99(&SparseHistogram::from(&h));Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".