diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/actors/helpers/mon_histogram_helper.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/actors/helpers/mon_histogram_helper.h')
-rw-r--r-- | library/cpp/actors/helpers/mon_histogram_helper.h | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/library/cpp/actors/helpers/mon_histogram_helper.h b/library/cpp/actors/helpers/mon_histogram_helper.h index 1e28ba31de..a9a57e3823 100644 --- a/library/cpp/actors/helpers/mon_histogram_helper.h +++ b/library/cpp/actors/helpers/mon_histogram_helper.h @@ -5,48 +5,48 @@ #include <util/string/cast.h> namespace NActors { - namespace NMon { - class THistogramCounterHelper { - public: - THistogramCounterHelper() - : FirstBucketVal(0) - , BucketCount(0) - { - } + namespace NMon { + class THistogramCounterHelper { + public: + THistogramCounterHelper() + : FirstBucketVal(0) + , BucketCount(0) + { + } THistogramCounterHelper(const THistogramCounterHelper&) = default; void Init(NMonitoring::TDynamicCounters* group, const TString& baseName, const TString& unit, ui64 firstBucket, ui64 bucketCnt, bool useSensorLabelName = true) { - Y_ASSERT(FirstBucketVal == 0); - Y_ASSERT(BucketCount == 0); + Y_ASSERT(FirstBucketVal == 0); + Y_ASSERT(BucketCount == 0); - FirstBucketVal = firstBucket; - BucketCount = bucketCnt; - BucketsHolder.reserve(BucketCount); - Buckets.reserve(BucketCount); - for (size_t i = 0; i < BucketCount; ++i) { - TString bucketName = GetBucketName(i) + " " + unit; + FirstBucketVal = firstBucket; + BucketCount = bucketCnt; + BucketsHolder.reserve(BucketCount); + Buckets.reserve(BucketCount); + for (size_t i = 0; i < BucketCount; ++i) { + TString bucketName = GetBucketName(i) + " " + unit; auto labelName = useSensorLabelName ? "sensor" : "name"; BucketsHolder.push_back(group->GetSubgroup(labelName, baseName)->GetNamedCounter("range", bucketName, true)); - Buckets.push_back(BucketsHolder.back().Get()); - } - } + Buckets.push_back(BucketsHolder.back().Get()); + } + } - void Add(ui64 val) { - Y_ASSERT(FirstBucketVal != 0); - Y_ASSERT(BucketCount != 0); - Y_VERIFY(val <= (1ULL << 63ULL)); - size_t ind = 0; - if (val > FirstBucketVal) { - ind = GetValueBitCount((2 * val - 1) / FirstBucketVal) - 1; - if (ind >= BucketCount) { - ind = BucketCount - 1; - } - } - Buckets[ind]->Inc(); - } + void Add(ui64 val) { + Y_ASSERT(FirstBucketVal != 0); + Y_ASSERT(BucketCount != 0); + Y_VERIFY(val <= (1ULL << 63ULL)); + size_t ind = 0; + if (val > FirstBucketVal) { + ind = GetValueBitCount((2 * val - 1) / FirstBucketVal) - 1; + if (ind >= BucketCount) { + ind = BucketCount - 1; + } + } + Buckets[ind]->Inc(); + } ui64 GetBucketCount() const { return BucketCount; @@ -62,25 +62,25 @@ namespace NActors { *Buckets[index] = value; } - private: - TString GetBucketName(size_t ind) const { - Y_ASSERT(FirstBucketVal != 0); - Y_ASSERT(BucketCount != 0); - Y_ASSERT(ind < BucketCount); - if (ind + 1 < BucketCount) { - return ToString<ui64>(FirstBucketVal << ind); - } else { - // Last slot is up to +INF - return "INF"; - } + private: + TString GetBucketName(size_t ind) const { + Y_ASSERT(FirstBucketVal != 0); + Y_ASSERT(BucketCount != 0); + Y_ASSERT(ind < BucketCount); + if (ind + 1 < BucketCount) { + return ToString<ui64>(FirstBucketVal << ind); + } else { + // Last slot is up to +INF + return "INF"; + } } - private: - ui64 FirstBucketVal; - ui64 BucketCount; - TVector<NMonitoring::TDynamicCounters::TCounterPtr> BucketsHolder; + private: + ui64 FirstBucketVal; + ui64 BucketCount; + TVector<NMonitoring::TDynamicCounters::TCounterPtr> BucketsHolder; TVector<NMonitoring::TDeprecatedCounter*> Buckets; - }; - + }; + } -} +} |