Class stores M buckets of type Counter and allows easy calculation of percentiles. More...
#include <userver/utils/statistics/percentile.hpp>
Public Member Functions | |
Percentile (const Percentile< M, Counter, ExtraBuckets, ExtraBucketSize > &other) noexcept | |
Percentile & | operator= (const Percentile &rhs) noexcept |
void | Account (size_t value) |
Account for another value. Value is truncated [0..M) and added to the corresponding bucket. | |
size_t | GetPercentile (double percent) const |
Get X percentile - min value P in [0..M) so that total number of elements in buckets 0..P is no less than X percent. | |
template<class Duration = std::chrono::seconds> | |
void | Add (const Percentile< M, Counter, ExtraBuckets, ExtraBucketSize > &other, Duration this_epoch_duration=Duration(), Duration before_this_epoch_duration=Duration()) |
void | Reset () |
Counter | Count () const |
Total number of elements. | |
Class stores M buckets of type Counter and allows easy calculation of percentiles.
Bucket X stores how many elements with value X was accounted for, for the first M buckets. Bucket X stores how many elements with values [X-ExtraBucketSize/2; X+ExtraBucketSize/2) were accounted for, for the next ExtraBuckets buckets.
M | how many buckets store precise value |
Counter | bucket type |
ExtraBuckets | how many buckets store approximated values |
ExtraBucketSize | ExtraBuckets store values with this precision |
Example: Precisely count for first 500 milliseconds of execution using uint32_t counters and leave 100 buckets for all the other values with precision of 42 milliseconds:
Definition at line 56 of file percentile.hpp.
|
inline |
Definition at line 58 of file percentile.hpp.
|
inlinenoexcept |
Definition at line 64 of file percentile.hpp.
|
inline |
Account for another value. Value is truncated [0..M) and added to the corresponding bucket.
Definition at line 91 of file percentile.hpp.
|
inline |
Definition at line 141 of file percentile.hpp.
|
inline |
Total number of elements.
Definition at line 167 of file percentile.hpp.
|
inline |
Get X percentile - min value P in [0..M) so that total number of elements in buckets 0..P is no less than X percent.
percent | - value in [0..100] - requested percentile if outside of 100, then returns last bucket that has any element in it. |
Definition at line 115 of file percentile.hpp.
|
inlinenoexcept |
Definition at line 69 of file percentile.hpp.
|
inline |
Definition at line 159 of file percentile.hpp.