aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/counters/histogram_ut.cpp
diff options
context:
space:
mode:
authorSergey Polovko <sergey@polovko.me>2022-02-10 16:47:02 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:02 +0300
commit3e0b762a82514bac89c1dd6ea7211e381d8aa248 (patch)
treec2d1b379ecaf05ca8f11ed0b5da9d1a950e6e554 /library/cpp/monlib/counters/histogram_ut.cpp
parentab3783171cc30e262243a0227c86118f7080c896 (diff)
downloadydb-3e0b762a82514bac89c1dd6ea7211e381d8aa248.tar.gz
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/counters/histogram_ut.cpp')
-rw-r--r--library/cpp/monlib/counters/histogram_ut.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/library/cpp/monlib/counters/histogram_ut.cpp b/library/cpp/monlib/counters/histogram_ut.cpp
index 5a0800505a..654994d12f 100644
--- a/library/cpp/monlib/counters/histogram_ut.cpp
+++ b/library/cpp/monlib/counters/histogram_ut.cpp
@@ -1,47 +1,47 @@
-#include "histogram.h"
-
+#include "histogram.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-using namespace NMonitoring;
-
+
+using namespace NMonitoring;
+
Y_UNIT_TEST_SUITE(THistorgamTest) {
Y_UNIT_TEST(TakeSnapshot) {
- THdrHistogram h(1, 10, 3);
- UNIT_ASSERT(h.RecordValue(1));
- UNIT_ASSERT(h.RecordValue(2));
- UNIT_ASSERT(h.RecordValues(3, 10));
- UNIT_ASSERT(h.RecordValue(4));
- UNIT_ASSERT(h.RecordValue(5));
-
- UNIT_ASSERT_EQUAL(h.GetTotalCount(), 14);
-
- THistogramSnapshot snapshot;
- h.TakeSnaphot(&snapshot);
-
- UNIT_ASSERT_EQUAL(h.GetTotalCount(), 0);
-
- UNIT_ASSERT_EQUAL(snapshot.Min, 1);
- UNIT_ASSERT_EQUAL(snapshot.Max, 5);
-
- // >>> a = [1, 2] + [3 for i in range(10)] + [4, 5]
- // >>> numpy.mean(a)
- // 3.0
- UNIT_ASSERT_DOUBLES_EQUAL(snapshot.Mean, 3.0, 1e-6);
-
- // >>> numpy.std(a)
- // 0.84515425472851657
- UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.84515425472851657, 1e-6);
-
- // >>> [(p, round(numpy.percentile(a, p))) for p in [50, 75, 90, 95, 98, 99, 99.9, 100]]
- // [(50, 3.0), (75, 3.0), (90, 4.0), (95, 4.0), (98, 5.0), (99, 5.0), (99.9, 5.0), (100, 5.0)]
- UNIT_ASSERT_EQUAL(snapshot.Percentile50, 3);
- UNIT_ASSERT_EQUAL(snapshot.Percentile75, 3);
- UNIT_ASSERT_EQUAL(snapshot.Percentile90, 4);
- UNIT_ASSERT_EQUAL(snapshot.Percentile95, 4);
- UNIT_ASSERT_EQUAL(snapshot.Percentile98, 5);
- UNIT_ASSERT_EQUAL(snapshot.Percentile99, 5);
- UNIT_ASSERT_EQUAL(snapshot.Percentile999, 5);
+ THdrHistogram h(1, 10, 3);
+ UNIT_ASSERT(h.RecordValue(1));
+ UNIT_ASSERT(h.RecordValue(2));
+ UNIT_ASSERT(h.RecordValues(3, 10));
+ UNIT_ASSERT(h.RecordValue(4));
+ UNIT_ASSERT(h.RecordValue(5));
+
+ UNIT_ASSERT_EQUAL(h.GetTotalCount(), 14);
+
+ THistogramSnapshot snapshot;
+ h.TakeSnaphot(&snapshot);
+
+ UNIT_ASSERT_EQUAL(h.GetTotalCount(), 0);
+
+ UNIT_ASSERT_EQUAL(snapshot.Min, 1);
+ UNIT_ASSERT_EQUAL(snapshot.Max, 5);
+
+ // >>> a = [1, 2] + [3 for i in range(10)] + [4, 5]
+ // >>> numpy.mean(a)
+ // 3.0
+ UNIT_ASSERT_DOUBLES_EQUAL(snapshot.Mean, 3.0, 1e-6);
+
+ // >>> numpy.std(a)
+ // 0.84515425472851657
+ UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.84515425472851657, 1e-6);
+
+ // >>> [(p, round(numpy.percentile(a, p))) for p in [50, 75, 90, 95, 98, 99, 99.9, 100]]
+ // [(50, 3.0), (75, 3.0), (90, 4.0), (95, 4.0), (98, 5.0), (99, 5.0), (99.9, 5.0), (100, 5.0)]
+ UNIT_ASSERT_EQUAL(snapshot.Percentile50, 3);
+ UNIT_ASSERT_EQUAL(snapshot.Percentile75, 3);
+ UNIT_ASSERT_EQUAL(snapshot.Percentile90, 4);
+ UNIT_ASSERT_EQUAL(snapshot.Percentile95, 4);
+ UNIT_ASSERT_EQUAL(snapshot.Percentile98, 5);
+ UNIT_ASSERT_EQUAL(snapshot.Percentile99, 5);
+ UNIT_ASSERT_EQUAL(snapshot.Percentile999, 5);
UNIT_ASSERT_EQUAL(snapshot.TotalCount, 14);
- }
-}
+ }
+}