diff options
Diffstat (limited to 'src/core/support/histogram.c')
-rw-r--r-- | src/core/support/histogram.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/support/histogram.c b/src/core/support/histogram.c index 673affde71..9029703891 100644 --- a/src/core/support/histogram.c +++ b/src/core/support/histogram.c @@ -164,7 +164,9 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) { size_t lower_idx; size_t upper_idx; - GPR_ASSERT(h->count >= 1); + if (h->count == 0) { + return 0.0; + } if (count_below <= 0) { return h->min_seen; @@ -189,12 +191,12 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) { break; } } - return (bucket_start(h, lower_idx) + bucket_start(h, upper_idx)) / 2.0; + return (bucket_start(h, (double)lower_idx) + bucket_start(h, (double)upper_idx)) / 2.0; } else { /* treat values as uniform throughout the bucket, and find where this value should lie */ - lower_bound = bucket_start(h, lower_idx); - upper_bound = bucket_start(h, lower_idx + 1); + lower_bound = bucket_start(h, (double)lower_idx); + upper_bound = bucket_start(h, (double)(lower_idx + 1)); return GPR_CLAMP(upper_bound - (upper_bound - lower_bound) * (count_so_far - count_below) / h->buckets[lower_idx], |