Struct hdrhistogram::Histogram
source · pub struct Histogram<T: Counter> { /* private fields */ }
Expand description
Histogram
is the core data structure in HdrSample. It records values, and performs analytics.
At its heart, it keeps the count for recorded samples in “buckets” of values. The resolution and distribution of these buckets is tuned based on the desired highest trackable value, as well as the user-specified number of significant decimal digits to preserve. The values for the buckets are kept in a way that resembles floats and doubles: there is a mantissa and an exponent, and each bucket represents a different exponent. The “sub-buckets” within a bucket represent different values for the mantissa.
To a first approximation, the sub-buckets of the first
bucket would hold the values 0
, 1
, 2
, 3
, …, the sub-buckets of the second bucket would
hold 0
, 2
, 4
, 6
, …, the third would hold 0
, 4
, 8
, and so on. However, the low
half of each bucket (except bucket 0) is unnecessary, since those values are already covered by
the sub-buckets of all the preceeding buckets. Thus, Histogram
keeps the top half of every
such bucket.
For the purposes of explanation, consider a Histogram
with 2048 sub-buckets for every bucket,
and a lowest discernible value of 1:
The 0th bucket covers 0...2047 in multiples of 1, using all 2048 sub-buckets The 1st bucket covers 2048..4097 in multiples of 2, using only the top 1024 sub-buckets The 2nd bucket covers 4096..8191 in multiple of 4, using only the top 1024 sub-buckets ...
Bucket 0 is “special” here. It is the only one that has 2048 entries. All the rest have
1024 entries (because their bottom half overlaps with and is already covered by the all of
the previous buckets put together). In other words, the k
’th bucket could represent 0 * 2^k
to 2048 * 2^k
in 2048 buckets with 2^k
precision, but the midpoint of 1024 * 2^k = 2048 * 2^(k-1)
, which is the k-1’th bucket’s end. So, we would use the previous bucket
for those lower values as it has better precision.
Implementations§
source§impl<T: Counter> Histogram<T>
impl<T: Counter> Histogram<T>
sourcepub fn distinct_values(&self) -> usize
pub fn distinct_values(&self) -> usize
Get the current number of distinct values that can be represented in the histogram.
sourcepub fn low(&self) -> u64
pub fn low(&self) -> u64
Get the lowest discernible value for the histogram in its current configuration.
sourcepub fn high(&self) -> u64
pub fn high(&self) -> u64
Get the highest trackable value for the histogram in its current configuration.
sourcepub fn count(&self) -> u64
👎Deprecated since 6.0.0: use len
instead
pub fn count(&self) -> u64
len
insteadGet the total number of samples recorded.
sourcepub fn buckets(&self) -> u8
pub fn buckets(&self) -> u8
Get the number of buckets used by the histogram to cover the highest trackable value.
This method differs from .len()
in that it does not count the sub buckets within each
bucket.
This method is probably only useful for testing purposes.
sourcepub fn is_auto_resize(&self) -> bool
pub fn is_auto_resize(&self) -> bool
Returns true if this histogram is currently able to auto-resize as new samples are recorded.
sourcepub fn clone_correct(&self, interval: u64) -> Histogram<T>
pub fn clone_correct(&self, interval: u64) -> Histogram<T>
Get a copy of this histogram, corrected for coordinated omission.
To compensate for the loss of sampled values when a recorded value is larger than the
expected interval between value samples, the new histogram will include an auto-generated
additional series of decreasingly-smaller (down to the interval
) value records for each
count found in the current histogram that is larger than the interval
.
Note: This is a post-correction method, as opposed to the at-recording correction method
provided by record_correct
. The two methods are mutually exclusive, and only one of the
two should be be used on a given data set to correct for the same coordinated omission
issue.
See notes in the description of the Histogram calls for an illustration of why this corrective behavior is important.
If interval
is larger than 0, add auto-generated value records as appropriate if value is
larger than interval
.
sourcepub fn set_to<B: Borrow<Histogram<T>>>(
&mut self,
source: B,
) -> Result<(), AdditionError>
pub fn set_to<B: Borrow<Histogram<T>>>( &mut self, source: B, ) -> Result<(), AdditionError>
Overwrite this histogram with the given histogram. All data and statistics in this histogram will be overwritten.
sourcepub fn set_to_corrected<B: Borrow<Histogram<T>>>(
&mut self,
source: B,
interval: u64,
) -> Result<(), RecordError>
pub fn set_to_corrected<B: Borrow<Histogram<T>>>( &mut self, source: B, interval: u64, ) -> Result<(), RecordError>
Overwrite this histogram with the given histogram while correcting for coordinated
omission. All data and statistics in this histogram will be overwritten. See
clone_correct
for more detailed explanation about how correction is applied
sourcepub fn add<B: Borrow<Histogram<T>>>(
&mut self,
source: B,
) -> Result<(), AdditionError>
pub fn add<B: Borrow<Histogram<T>>>( &mut self, source: B, ) -> Result<(), AdditionError>
Add the contents of another histogram to this one.
Returns an error if values in the other histogram cannot be stored; see AdditionError
.
sourcepub fn add_correct<B: Borrow<Histogram<T>>>(
&mut self,
source: B,
interval: u64,
) -> Result<(), RecordError>
pub fn add_correct<B: Borrow<Histogram<T>>>( &mut self, source: B, interval: u64, ) -> Result<(), RecordError>
Add the contents of another histogram to this one, while correcting for coordinated omission.
To compensate for the loss of sampled values when a recorded value is larger than the
expected interval between value samples, the values added will include an auto-generated
additional series of decreasingly-smaller (down to the given interval
) value records for
each count found in the current histogram that is larger than interval
.
Note: This is a post-recording correction method, as opposed to the at-recording correction
method provided by record_correct
. The two methods are mutually exclusive, and only one
of the two should be be used on a given data set to correct for the same coordinated
omission issue.
See notes in the description of the Histogram
calls for an illustration of why this
corrective behavior is important.
See RecordError
for error conditions.
sourcepub fn subtract<B: Borrow<Histogram<T>>>(
&mut self,
subtrahend: B,
) -> Result<(), SubtractionError>
pub fn subtract<B: Borrow<Histogram<T>>>( &mut self, subtrahend: B, ) -> Result<(), SubtractionError>
Subtract the contents of another histogram from this one.
See SubtractionError
for error conditions.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the contents of this histogram while preserving its statistics and configuration.
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the contents and statistics of this histogram, preserving only its configuration.
sourcepub fn auto(&mut self, enabled: bool)
pub fn auto(&mut self, enabled: bool)
Control whether or not the histogram can auto-resize and auto-adjust it’s highest trackable value as high-valued samples are recorded.
sourcepub fn new(sigfig: u8) -> Result<Histogram<T>, CreationError>
pub fn new(sigfig: u8) -> Result<Histogram<T>, CreationError>
Construct an auto-resizing Histogram
with a lowest discernible value of 1 and an
auto-adjusting highest trackable value. Can auto-resize up to track values up to
(i64::max_value() / 2)
.
See new_with_bounds
for info on sigfig
.
sourcepub fn new_with_max(
high: u64,
sigfig: u8,
) -> Result<Histogram<T>, CreationError>
pub fn new_with_max( high: u64, sigfig: u8, ) -> Result<Histogram<T>, CreationError>
Construct a Histogram
given a known maximum value to be tracked, and a number of
significant decimal digits. The histogram will be constructed to implicitly track
(distinguish from 0) values as low as 1. Auto-resizing will be disabled.
See new_with_bounds
for info on high
and sigfig
.
sourcepub fn new_with_bounds(
low: u64,
high: u64,
sigfig: u8,
) -> Result<Histogram<T>, CreationError>
pub fn new_with_bounds( low: u64, high: u64, sigfig: u8, ) -> Result<Histogram<T>, CreationError>
Construct a Histogram
with known upper and lower bounds for recorded sample values.
low
is the lowest value that can be discerned (distinguished from 0) by the histogram,
and must be a positive integer that is >= 1. It may be internally rounded down to nearest
power of 2. Providing a lowest discernible value (low
) is useful is situations where the
units used for the histogram’s values are much smaller that the minimal accuracy required.
E.g. when tracking time values stated in nanosecond units, where the minimal accuracy
required is a microsecond, the proper value for low
would be 1000. If you’re not sure,
use 1.
high
is the highest value to be tracked by the histogram, and must be a
positive integer that is >= (2 * low)
. If you’re not sure, use u64::max_value()
.
sigfig
Specifies the number of significant figures to maintain. This is the number of
significant decimal digits to which the histogram will maintain value resolution and
separation. Must be in the range [0, 5]. If you’re not sure, use 3. As sigfig
increases,
memory usage grows exponentially, so choose carefully if there will be many histograms in
memory at once or if storage is otherwise a concern.
Returns an error if the provided parameters are invalid; see CreationError
.
sourcepub fn new_from<F: Counter>(source: &Histogram<F>) -> Histogram<T>
pub fn new_from<F: Counter>(source: &Histogram<F>) -> Histogram<T>
Construct a Histogram
with the same range settings as a given source histogram,
duplicating the source’s start/end timestamps (but NOT its contents).
sourcepub fn record(&mut self, value: u64) -> Result<(), RecordError>
pub fn record(&mut self, value: u64) -> Result<(), RecordError>
Record value
in the histogram.
Returns an error if value
exceeds the highest trackable value and auto-resize is
disabled.
sourcepub fn saturating_record(&mut self, value: u64)
pub fn saturating_record(&mut self, value: u64)
Record value
in the histogram, clamped to the range of the histogram.
This method cannot fail, as any values that are too small or too large to be tracked will automatically be clamed to be in range. Be aware that this will hide extreme outliers from the resulting histogram without warning. Since the values are clamped, the histogram will also not be resized to accomodate the value, even if auto-resize is enabled.
sourcepub fn record_n(&mut self, value: u64, count: T) -> Result<(), RecordError>
pub fn record_n(&mut self, value: u64, count: T) -> Result<(), RecordError>
Record multiple samples for a value in the histogram, adding to the value’s current count.
count
is the number of occurrences of this value to record.
Returns an error if value
cannot be recorded; see RecordError
.
sourcepub fn saturating_record_n(&mut self, value: u64, count: T)
pub fn saturating_record_n(&mut self, value: u64, count: T)
Record multiple samples for a value in the histogram, each one clamped to the histogram’s range.
count
is the number of occurrences of this value to record.
This method cannot fail, as values that are too small or too large to be recorded will automatically be clamed to be in range. Be aware that this will hide extreme outliers from the resulting histogram without warning. Since the values are clamped, the histogram will also not be resized to accomodate the value, even if auto-resize is enabled.
sourcepub fn record_correct(
&mut self,
value: u64,
interval: u64,
) -> Result<(), RecordError>
pub fn record_correct( &mut self, value: u64, interval: u64, ) -> Result<(), RecordError>
Record a value in the histogram while correcting for coordinated omission.
See record_n_correct
for further documentation.
sourcepub fn record_n_correct(
&mut self,
value: u64,
count: T,
interval: u64,
) -> Result<(), RecordError>
pub fn record_n_correct( &mut self, value: u64, count: T, interval: u64, ) -> Result<(), RecordError>
Record multiple values in the histogram while correcting for coordinated omission.
To compensate for the loss of sampled values when a recorded value is larger than the
expected interval between value samples, this method will auto-generate and record an
additional series of decreasingly-smaller (down to interval
) value records.
Note: This is a at-recording correction method, as opposed to the post-recording correction
method provided by correct_clone
. The two methods are mutually exclusive, and only one of
the two should be be used on a given data set to correct for the same coordinated omission
issue.
Returns an error if value
exceeds the highest trackable value and auto-resize is
disabled.
sourcepub fn iter_quantiles(
&self,
ticks_per_half_distance: u32,
) -> HistogramIterator<'_, T, Iter<'_, T>> ⓘ
pub fn iter_quantiles( &self, ticks_per_half_distance: u32, ) -> HistogramIterator<'_, T, Iter<'_, T>> ⓘ
Iterate through histogram values by quantile levels.
The iteration mechanic for this iterator may appear somewhat confusing, but it yields
fairly pleasing output. The iterator starts with a quantile step size of
1/halving_period
. For every iteration, it yields a value whose quantile is that much
greater than the previously emitted quantile (i.e., initially 0, 0.1, 0.2, etc.). Once
halving_period
values have been emitted, the quantile step size is halved, and the
iteration continues.
ticks_per_half_distance
must be at least 1.
The iterator yields an iterators::IterationValue
struct.
One subtlety of this iterator is that you can reach a value whose cumulative count yields
a quantile of 1.0 far sooner than the quantile iteration would reach 1.0. Consider a
histogram with count 1 at value 1, and count 1000000 at value 1000. At any quantile
iteration above 1/1000001 = 0.000000999
, iteration will have necessarily proceeded to
the index for value 1000, which has all the remaining counts, and therefore quantile (for
the value) of 1.0. This is why IterationValue
has both quantile()
and
quantile_iterated_to()
. Additionally, to avoid a bunch of unhelpful iterations once
iteration has reached the last value with non-zero count, quantile iteration will skip
straight to 1.0 as well.
use hdrhistogram::Histogram;
use hdrhistogram::iterators::IterationValue;
let mut hist = Histogram::<u64>::new_with_max(10000, 4).unwrap();
for i in 0..10000 {
hist += i;
}
let mut perc = hist.iter_quantiles(1);
println!("{:?}", hist.iter_quantiles(1).collect::<Vec<_>>());
assert_eq!(
perc.next(),
Some(IterationValue::new(hist.value_at_quantile(0.0001), 0.0001, 0.0, 1, 1))
);
// step size = 50
assert_eq!(
perc.next(),
Some(IterationValue::new(hist.value_at_quantile(0.5), 0.5, 0.5, 1, 5000 - 1))
);
// step size = 25
assert_eq!(
perc.next(),
Some(IterationValue::new(hist.value_at_quantile(0.75), 0.75, 0.75, 1, 2500))
);
// step size = 12.5
assert_eq!(
perc.next(),
Some(IterationValue::new(hist.value_at_quantile(0.875), 0.875, 0.875, 1, 1250))
);
// step size = 6.25
assert_eq!(
perc.next(),
Some(IterationValue::new(hist.value_at_quantile(0.9375), 0.9375, 0.9375, 1, 625))
);
// step size = 3.125
assert_eq!(
perc.next(),
Some(IterationValue::new(hist.value_at_quantile(0.9688), 0.9688, 0.96875, 1, 313))
);
// etc...
sourcepub fn iter_linear(&self, step: u64) -> HistogramIterator<'_, T, Iter<'_, T>> ⓘ
pub fn iter_linear(&self, step: u64) -> HistogramIterator<'_, T, Iter<'_, T>> ⓘ
Iterates through histogram values using linear value steps. The iteration is performed in
steps of size step
, each one yielding the count for all values in the preceeding value
range of size step
. The iterator terminates when all recorded histogram values are
exhausted.
The iterator yields an iterators::IterationValue
struct.
use hdrhistogram::Histogram;
use hdrhistogram::iterators::IterationValue;
let mut hist = Histogram::<u64>::new_with_max(1000, 3).unwrap();
hist += 100;
hist += 500;
hist += 800;
hist += 850;
let mut perc = hist.iter_linear(100);
assert_eq!(
perc.next(),
Some(IterationValue::new(99, hist.quantile_below(99), hist.quantile_below(99), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(199, hist.quantile_below(199), hist.quantile_below(199), 0, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(299, hist.quantile_below(299), hist.quantile_below(299), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(399, hist.quantile_below(399), hist.quantile_below(399), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(499, hist.quantile_below(499), hist.quantile_below(499), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(599, hist.quantile_below(599), hist.quantile_below(599), 0, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(699, hist.quantile_below(699), hist.quantile_below(699), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(799, hist.quantile_below(799), hist.quantile_below(799), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(899, hist.quantile_below(899), hist.quantile_below(899), 0, 2))
);
assert_eq!(perc.next(), None);
sourcepub fn iter_log(
&self,
start: u64,
exp: f64,
) -> HistogramIterator<'_, T, Iter<'_, T>> ⓘ
pub fn iter_log( &self, start: u64, exp: f64, ) -> HistogramIterator<'_, T, Iter<'_, T>> ⓘ
Iterates through histogram values at logarithmically increasing levels. The iteration is
performed in steps that start at start
and increase exponentially according to exp
. The
iterator terminates when all recorded histogram values are exhausted.
The iterator yields an iterators::IterationValue
struct.
use hdrhistogram::Histogram;
use hdrhistogram::iterators::IterationValue;
let mut hist = Histogram::<u64>::new_with_max(1000, 3).unwrap();
hist += 100;
hist += 500;
hist += 800;
hist += 850;
let mut perc = hist.iter_log(1, 10.0);
assert_eq!(
perc.next(),
Some(IterationValue::new(0, hist.quantile_below(0), hist.quantile_below(0), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(9, hist.quantile_below(9), hist.quantile_below(9), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(99, hist.quantile_below(99), hist.quantile_below(99), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(999, hist.quantile_below(999), hist.quantile_below(999), 0, 4))
);
assert_eq!(perc.next(), None);
sourcepub fn iter_recorded(&self) -> HistogramIterator<'_, T, Iter> ⓘ
pub fn iter_recorded(&self) -> HistogramIterator<'_, T, Iter> ⓘ
Iterates through all recorded histogram values using the finest granularity steps supported by the underlying representation. The iteration steps through all non-zero recorded value counts, and terminates when all recorded histogram values are exhausted.
The iterator yields an iterators::IterationValue
struct.
use hdrhistogram::Histogram;
use hdrhistogram::iterators::IterationValue;
let mut hist = Histogram::<u64>::new_with_max(1000, 3).unwrap();
hist += 100;
hist += 500;
hist += 800;
hist += 850;
let mut perc = hist.iter_recorded();
assert_eq!(
perc.next(),
Some(IterationValue::new(100, hist.quantile_below(100), hist.quantile_below(100), 1, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(500, hist.quantile_below(500), hist.quantile_below(500), 1, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(800, hist.quantile_below(800), hist.quantile_below(800), 1, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(850, hist.quantile_below(850), hist.quantile_below(850), 1, 1))
);
assert_eq!(perc.next(), None);
sourcepub fn iter_all(&self) -> HistogramIterator<'_, T, Iter> ⓘ
pub fn iter_all(&self) -> HistogramIterator<'_, T, Iter> ⓘ
Iterates through all histogram values using the finest granularity steps supported by the underlying representation. The iteration steps through all possible unit value levels, regardless of whether or not there were recorded values for that value level, and terminates when all recorded histogram values are exhausted.
The iterator yields an iterators::IterationValue
struct.
use hdrhistogram::Histogram;
use hdrhistogram::iterators::IterationValue;
let mut hist = Histogram::<u64>::new_with_max(10, 1).unwrap();
hist += 1;
hist += 5;
hist += 8;
let mut perc = hist.iter_all();
assert_eq!(perc.next(), Some(IterationValue::new(0, 0.0, 0.0, 0, 0)));
assert_eq!(
perc.next(),
Some(IterationValue::new(1, hist.quantile_below(1), hist.quantile_below(1), 1, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(2, hist.quantile_below(2), hist.quantile_below(2), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(3, hist.quantile_below(3), hist.quantile_below(3), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(4, hist.quantile_below(4), hist.quantile_below(4), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(5, hist.quantile_below(5), hist.quantile_below(5), 1, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(6, hist.quantile_below(6), hist.quantile_below(6), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(7, hist.quantile_below(7), hist.quantile_below(7), 0, 0))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(8, hist.quantile_below(8), hist.quantile_below(8), 1, 1))
);
assert_eq!(
perc.next(),
Some(IterationValue::new(9, hist.quantile_below(9), hist.quantile_below(9), 0, 0))
);
assert_eq!(perc.next(), Some(IterationValue::new(10, 1.0, 1.0, 0, 0)));
sourcepub fn min(&self) -> u64
pub fn min(&self) -> u64
Get the lowest recorded value level in the histogram. If the histogram has no recorded values, the value returned will be 0.
sourcepub fn max(&self) -> u64
pub fn max(&self) -> u64
Get the highest recorded value level in the histogram. If the histogram has no recorded values, the value returned is undefined.
sourcepub fn min_nz(&self) -> u64
pub fn min_nz(&self) -> u64
Get the lowest recorded non-zero value level in the histogram.
If the histogram has no recorded values, the value returned is u64::max_value()
.
sourcepub fn equivalent(&self, value1: u64, value2: u64) -> bool
pub fn equivalent(&self, value1: u64, value2: u64) -> bool
Determine if two values are equivalent with the histogram’s resolution. Equivalent here means that value samples recorded for any two equivalent values are counted in a common total count.
sourcepub fn stdev(&self) -> f64
pub fn stdev(&self) -> f64
Get the computed standard deviation of all recorded values in the histogram
sourcepub fn value_at_percentile(&self, percentile: f64) -> u64
pub fn value_at_percentile(&self, percentile: f64) -> u64
Get the value at a given percentile.
This is simply value_at_quantile
multiplied by 100.0. For best floating-point precision,
use value_at_quantile
directly.
sourcepub fn value_at_quantile(&self, quantile: f64) -> u64
pub fn value_at_quantile(&self, quantile: f64) -> u64
Get the value at a given quantile.
When the given quantile is > 0.0, the value returned is the value that the given percentage of the overall recorded value entries in the histogram are either smaller than or equivalent to. When the given quantile is 0.0, the value returned is the value that all value entries in the histogram are either larger than or equivalent to.
Two values are considered “equivalent” if self.equivalent
would return true.
If the total count of the histogram has exceeded u64::max_value()
, this will return
inaccurate results.
sourcepub fn percentile_below(&self, value: u64) -> f64
pub fn percentile_below(&self, value: u64) -> f64
Get the percentile of samples at and below a given value.
This is simply quantile_below* multiplied by 100.0. For best floating-point precision, use
quantile_below` directly.
sourcepub fn quantile_below(&self, value: u64) -> f64
pub fn quantile_below(&self, value: u64) -> f64
Get the quantile of samples at or below a given value.
The value returned is the quantile of values recorded in the histogram that are smaller than or equivalent to the given value.
Two values are considered “equivalent” if self.equivalent
would return true.
If the value is larger than the maximum representable value, it will be clamped to the max representable value.
If the total count of the histogram has reached u64::max_value()
, this will return
inaccurate results.
sourcepub fn count_between(&self, low: u64, high: u64) -> u64
pub fn count_between(&self, low: u64, high: u64) -> u64
Get the count of recorded values within a range of value levels (inclusive to within the histogram’s resolution).
low
gives the lower value bound on the range for which to provide the recorded count.
Will be rounded down with lowest_equivalent
. Similarly, high
gives the higher value
bound on the range, and will be rounded up with highest_equivalent
. The function returns
the total count of values recorded in the histogram within the value range that is >= lowest_equivalent(low)
and <= highest_equivalent(high)
.
If either value is larger than the maximum representable value, it will be clamped to the max representable value.
The count will saturate at u64::max_value().
sourcepub fn count_at(&self, value: u64) -> T
pub fn count_at(&self, value: u64) -> T
Get the count of recorded values at a specific value (to within the histogram resolution at the value level).
The count is computed across values recorded in the histogram that are within the value
range that is >= lowest_equivalent(value)
and <= highest_equivalent(value)
.
If the value is larger than the maximum representable value, it will be clamped to the max representable value.
sourcepub fn lowest_equivalent(&self, value: u64) -> u64
pub fn lowest_equivalent(&self, value: u64) -> u64
Get the lowest value that is equivalent to the given value within the histogram’s resolution. Equivalent here means that value samples recorded for any two equivalent values are counted in a common total count.
sourcepub fn highest_equivalent(&self, value: u64) -> u64
pub fn highest_equivalent(&self, value: u64) -> u64
Get the highest value that is equivalent to the given value within the histogram’s resolution. Equivalent here means that value samples recorded for any two equivalent values are counted in a common total count.
Note that the return value is capped at u64::max_value()
.
sourcepub fn median_equivalent(&self, value: u64) -> u64
pub fn median_equivalent(&self, value: u64) -> u64
Get a value that lies in the middle (rounded up) of the range of values equivalent the given value. Equivalent here means that value samples recorded for any two equivalent values are counted in a common total count.
Note that the return value is capped at u64::max_value()
.
sourcepub fn next_non_equivalent(&self, value: u64) -> u64
pub fn next_non_equivalent(&self, value: u64) -> u64
Get the next value that is not equivalent to the given value within the histogram’s resolution. Equivalent means that value samples recorded for any two equivalent values are counted in a common total count.
Note that the return value is capped at u64::max_value()
.
sourcepub fn equivalent_range(&self, value: u64) -> u64
pub fn equivalent_range(&self, value: u64) -> u64
Get the size (in value units) of the range of values that are equivalent to the given value within the histogram’s resolution. Equivalent here means that value samples recorded for any two equivalent values are counted in a common total count.
Trait Implementations§
source§impl<'a, T: Counter> AddAssign<&'a Histogram<T>> for Histogram<T>
impl<'a, T: Counter> AddAssign<&'a Histogram<T>> for Histogram<T>
source§fn add_assign(&mut self, source: &'a Histogram<T>)
fn add_assign(&mut self, source: &'a Histogram<T>)
+=
operation. Read moresource§impl<T: Counter> AddAssign<u64> for Histogram<T>
impl<T: Counter> AddAssign<u64> for Histogram<T>
source§fn add_assign(&mut self, value: u64)
fn add_assign(&mut self, value: u64)
+=
operation. Read moresource§impl<T: Counter> AddAssign for Histogram<T>
impl<T: Counter> AddAssign for Histogram<T>
source§fn add_assign(&mut self, source: Histogram<T>)
fn add_assign(&mut self, source: Histogram<T>)
+=
operation. Read moresource§impl<'a, T: Counter> SubAssign<&'a Histogram<T>> for Histogram<T>
impl<'a, T: Counter> SubAssign<&'a Histogram<T>> for Histogram<T>
source§fn sub_assign(&mut self, other: &'a Histogram<T>)
fn sub_assign(&mut self, other: &'a Histogram<T>)
-=
operation. Read moreAuto Trait Implementations§
impl<T> Freeze for Histogram<T>
impl<T> RefUnwindSafe for Histogram<T>where
T: RefUnwindSafe,
impl<T> Send for Histogram<T>where
T: Send,
impl<T> Sync for Histogram<T>where
T: Sync,
impl<T> Unpin for Histogram<T>where
T: Unpin,
impl<T> UnwindSafe for Histogram<T>where
T: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)