From 463642ff61319b17b3371ee1fd6d6382b35ef476 Mon Sep 17 00:00:00 2001 From: kernelai Date: Fri, 21 Jan 2022 10:12:54 +0000 Subject: [PATCH] =?UTF-8?q?optimize=EF=BC=9Aremove=20calculate=20differenc?= =?UTF-8?q?e=20value=20in=20histogram?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/histogram.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/histogram.cc b/util/histogram.cc index 7af4030..5d89eed 100644 --- a/util/histogram.cc +++ b/util/histogram.cc @@ -216,8 +216,7 @@ double Histogram::Percentile(double p) const { double left_point = (b == 0) ? 0 : kBucketLimit[b - 1]; double right_point = kBucketLimit[b]; double left_sum = sum - buckets_[b]; - double right_sum = sum; - double pos = (threshold - left_sum) / (right_sum - left_sum); + double pos = (threshold - left_sum) / buckets_[b]; double r = left_point + (right_point - left_point) * pos; if (r < min_) r = min_; if (r > max_) r = max_;