1 #ifndef jb_event_rate_histogram_hpp 2 #define jb_event_rate_histogram_hpp 66 typename duration_type = std::chrono::microseconds,
67 typename counter_type = int,
typename rate_counter_type =
int>
69 :
private histogram<integer_range_binning<std::uint64_t>, counter_type> {
90 std::uint64_t max_expected_rate, duration_type measurement_period,
91 duration_type sampling_period = duration_type(1))
92 : rate_histogram(binning_strategy(0, max_expected_rate))
93 ,
rate_(measurement_period, sampling_period)
99 rate_.
sample(ts, [
this](std::uint64_t rate, std::uint64_t repeats) {
108 throw std::invalid_argument(
"No sample recorded yet");
133 #endif // jb_event_rate_histogram_hpp
Keep a histogram of observed event rates.
std::uint64_t last_rate() const
Get the last sample, if any.
A histogram class with controllable binning and range strategy.
integer_range_binning< std::uint64_t > binning_strategy
void sample(duration_type ts)
Record a new sample.
histogram< binning_strategy, counter_type > rate_histogram
event_rate_histogram(std::uint64_t max_expected_rate, duration_type measurement_period, duration_type sampling_period=duration_type(1))
Constructor.
sample_type estimated_quantile(double q) const
Estimate a quantile of the sample distribution.
sample_type observed_max() const
Return the largest sample value observed to this point.
void sample(duration_type ts, functor update)
Record a sample.
std::uint64_t underflow_count() const
Return the number of samples smaller than the histogram range.
sample_type observed_min() const
Return the smallest sample value observed to this point.
sample_type estimated_mean() const
Estimate the mean of the sample distribution.
event_rate_estimator< duration_type, rate_counter_type > rate_
std::uint64_t nsamples() const
Return the number of samples observed to this point.
void weighted_sample(sample_type const &t, counter_type weight)
Record a new sample.
std::uint64_t overflow_count() const
Return the number of samples larger than the histogram range.
The top-level namespace for the JayBeams library.