pub struct Histogram { /* private fields */ }Expand description
A basic Histogram type.
Implementations§
Source§impl Histogram
impl Histogram
Sourcepub const fn new(sig_figs: i32) -> Self
pub const fn new(sig_figs: i32) -> Self
Create a new histogram with the specified number of sig_figs.
§Panics
Under the same conditions as SigFigBucketizer::new.
Sourcepub fn sig_figs(&self) -> i32
pub fn sig_figs(&self) -> i32
Return the nubmer of significant figures in use for this histogram.
Sourcepub fn observe(&mut self, x: f64) -> Result<(), Error>
pub fn observe(&mut self, x: f64) -> Result<(), Error>
Observe a value x and increment the bucket for x.
This will never fail with Error::ExceedsMax because it will resize.
Sourcepub fn observe_n(&mut self, x: f64, n: u64) -> Result<(), Error>
pub fn observe_n(&mut self, x: f64, n: u64) -> Result<(), Error>
Observe a value x and increment its bucket n times.
This will never fail with Error::ExceedsMax because it will resize.
Sourcepub fn iter(&self) -> impl Iterator<Item = (f64, u64)> + '_
pub fn iter(&self) -> impl Iterator<Item = (f64, u64)> + '_
Return an iterator over this bucket.
Sourcepub fn dump<W: Write>(&self, w: W) -> Result<(), Error>
pub fn dump<W: Write>(&self, w: W) -> Result<(), Error>
Dump a histogram to the specified writer.
Sourcepub fn downsample(&self, sig_figs: i32) -> Self
pub fn downsample(&self, sig_figs: i32) -> Self
Create a new histogram downsampled to the specified number of significant figures.
§Panics
If sig_figs < 1 or sig_figs > 4 or sig_figs > self.sig_figs().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Histogram
impl RefUnwindSafe for Histogram
impl Send for Histogram
impl Sync for Histogram
impl Unpin for Histogram
impl UnwindSafe for Histogram
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more