aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/duration_histogram.h
diff options
context:
space:
mode:
authornga <nga@yandex-team.ru>2022-02-10 16:48:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:09 +0300
commitc2a1af049e9deca890e9923abe64fe6c59060348 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/messagebus/duration_histogram.h
parent1f553f46fb4f3c5eec631352cdd900a0709016af (diff)
downloadydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/duration_histogram.h')
-rw-r--r--library/cpp/messagebus/duration_histogram.h76
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/messagebus/duration_histogram.h b/library/cpp/messagebus/duration_histogram.h
index bda8c85704..ed060b0101 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;
-};
+};