Go to the documentation of this file.
61 return static_cast<size_t>(
log(
x) * h->one_on_log_multiplier);
74 return pow(h->multiplier,
x);
78 double max_bucket_start) {
84 h->sum_of_squares = 0.0;
85 h->multiplier = 1.0 + resolution;
86 h->one_on_log_multiplier = 1.0 /
log(1.0 + resolution);
87 h->max_possible = max_bucket_start;
89 h->min_seen = max_bucket_start;
106 h->sum_of_squares +=
x *
x;
108 if (x < h->min_seen) {
111 if (
x > h->max_seen) {
131 double min_seen,
double max_seen,
double sum,
132 double sum_of_squares,
double count) {
138 if (min_seen < histogram->min_seen) {
160 if (count_below <= 0) {
163 if (count_below >= h->count) {
169 for (lower_idx = 0; lower_idx < h->num_buckets; lower_idx++) {
170 count_so_far += h->buckets[lower_idx];
171 if (count_so_far >= count_below) {
175 if (count_so_far == count_below) {
178 for (upper_idx = lower_idx + 1; upper_idx < h->num_buckets; upper_idx++) {
179 if (h->buckets[upper_idx]) {
183 return (
bucket_start(h,
static_cast<double>(lower_idx)) +
189 lower_bound =
bucket_start(h,
static_cast<double>(lower_idx));
190 upper_bound =
bucket_start(h,
static_cast<double>(lower_idx + 1));
192 (count_so_far - count_below) /
193 h->buckets[lower_idx],
194 h->min_seen, h->max_seen);
204 return h->sum / h->count;
212 if (h->count == 0)
return 0.0;
213 return (h->sum_of_squares * h->count - h->sum * h->sum) /
214 (h->count * h->count);
226 return h->sum_of_squares;
void grpc_histogram_merge_contents(grpc_histogram *histogram, const uint32_t *data, size_t data_count, double min_seen, double max_seen, double sum, double sum_of_squares, double count)
static size_t bucket_for_unchecked(grpc_histogram *h, double x)
double sum(const T &container, F functor)
GPRAPI void gpr_free(void *ptr)
GPRAPI void * gpr_malloc(size_t size)
def percentile(N, percent, key=lambda x:x)
double grpc_histogram_minimum(grpc_histogram *h)
GPRAPI void * gpr_zalloc(size_t size)
static double threshold_for_count_below(grpc_histogram *h, double count_below)
double grpc_histogram_count(grpc_histogram *h)
void grpc_histogram_destroy(grpc_histogram *h)
static grpc_histogram * histogram
static double bucket_start(grpc_histogram *h, double x)
static size_t bucket_for(grpc_histogram *h, double x)
double grpc_histogram_percentile(grpc_histogram *h, double percentile)
double one_on_log_multiplier
double grpc_histogram_stddev(grpc_histogram *h)
double grpc_histogram_variance(grpc_histogram *h)
grpc_histogram * grpc_histogram_create(double resolution, double max_bucket_start)
T Clamp(T val, T min, T max)
double grpc_histogram_maximum(grpc_histogram *h)
double grpc_histogram_sum(grpc_histogram *h)
double grpc_histogram_sum_of_squares(grpc_histogram *h)
double grpc_histogram_mean(grpc_histogram *h)
void grpc_histogram_add(grpc_histogram *h, double x)
const uint32_t * grpc_histogram_get_contents(grpc_histogram *histogram, size_t *count)
int grpc_histogram_merge(grpc_histogram *dst, const grpc_histogram *src)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:12