diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/messagebus/duration_histogram.h | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/duration_histogram.h')
-rw-r--r-- | library/cpp/messagebus/duration_histogram.h | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/messagebus/duration_histogram.h b/library/cpp/messagebus/duration_histogram.h index ed060b0101..bda8c85704 100644 --- a/library/cpp/messagebus/duration_histogram.h +++ b/library/cpp/messagebus/duration_histogram.h @@ -1,45 +1,45 @@ -#pragma once - -#include <util/datetime/base.h> +#pragma once + +#include <util/datetime/base.h> #include <util/generic/bitops.h> #include <util/generic/string.h> - + #include <array> - -struct TDurationHistogram { - static const unsigned Buckets = 20; + +struct TDurationHistogram { + static const unsigned Buckets = 20; std::array<ui64, Buckets> Times; - - static const unsigned SecondBoundary = 11; - - TDurationHistogram() { + + static const unsigned SecondBoundary = 11; + + TDurationHistogram() { Times.fill(0); - } - - static unsigned BucketFor(TDuration d) { - ui64 units = d.MicroSeconds() * (1 << SecondBoundary) / 1000000; - if (units == 0) { - return 0; - } - unsigned bucket = GetValueBitCount(units) - 1; - if (bucket >= Buckets) { - bucket = Buckets - 1; - } - return bucket; - } - - void AddTime(TDuration d) { - Times[BucketFor(d)] += 1; - } - - TDurationHistogram& operator+=(const TDurationHistogram& that) { - for (unsigned i = 0; i < Times.size(); ++i) { - Times[i] += that.Times[i]; - } - return *this; - } - + } + + static unsigned BucketFor(TDuration d) { + ui64 units = d.MicroSeconds() * (1 << SecondBoundary) / 1000000; + if (units == 0) { + return 0; + } + unsigned bucket = GetValueBitCount(units) - 1; + if (bucket >= Buckets) { + bucket = Buckets - 1; + } + return bucket; + } + + void AddTime(TDuration d) { + Times[BucketFor(d)] += 1; + } + + TDurationHistogram& operator+=(const TDurationHistogram& that) { + for (unsigned i = 0; i < Times.size(); ++i) { + Times[i] += that.Times[i]; + } + return *this; + } + static TString LabelBefore(unsigned i); - + TString PrintToString() const; -}; +}; |