aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/metrics/ewma_ut.cpp
diff options
context:
space:
mode:
authormsherbakov <msherbakov@yandex-team.ru>2022-02-10 16:49:16 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:16 +0300
commitc224a621661ddd69699f9476922eb316607ef57e (patch)
tree33f4d878aa0a9faa964005e06bfab0272313aa71 /library/cpp/monlib/metrics/ewma_ut.cpp
parent29d0b2eeae154d04156e0698067c0c21a97ea61d (diff)
downloadydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/ewma_ut.cpp')
-rw-r--r--library/cpp/monlib/metrics/ewma_ut.cpp208
1 files changed, 104 insertions, 104 deletions
diff --git a/library/cpp/monlib/metrics/ewma_ut.cpp b/library/cpp/monlib/metrics/ewma_ut.cpp
index 01ef2478f7..2765c68eae 100644
--- a/library/cpp/monlib/metrics/ewma_ut.cpp
+++ b/library/cpp/monlib/metrics/ewma_ut.cpp
@@ -1,112 +1,112 @@
-#include "ewma.h"
+#include "ewma.h"
#include "metric.h"
-
+
#include <library/cpp/testing/unittest/registar.h>
-
-
-using namespace NMonitoring;
-
-const auto EPS = 1e-6;
-void ElapseMinute(IExpMovingAverage& ewma) {
- for (auto i = 0; i < 12; ++i) {
- ewma.Tick();
- }
-}
-
-Y_UNIT_TEST_SUITE(TEwmaTest) {
- Y_UNIT_TEST(OneMinute) {
+
+
+using namespace NMonitoring;
+
+const auto EPS = 1e-6;
+void ElapseMinute(IExpMovingAverage& ewma) {
+ for (auto i = 0; i < 12; ++i) {
+ ewma.Tick();
+ }
+}
+
+Y_UNIT_TEST_SUITE(TEwmaTest) {
+ Y_UNIT_TEST(OneMinute) {
TGauge gauge;
-
+
auto ewma = OneMinuteEwma(&gauge);
- ewma->Update(3);
- ewma->Tick();
-
- TVector<double> expectedValues {
- 0.6,
- 0.22072766,
- 0.08120117,
- 0.02987224,
- 0.01098938,
- 0.00404277,
- 0.00148725,
- 0.00054713,
- 0.00020128,
- 0.00007405,
- 0.00002724,
- 0.00001002,
- 0.00000369,
- 0.00000136,
- 0.00000050,
- 0.00000018,
- };
-
- for (auto expectedValue : expectedValues) {
- UNIT_ASSERT_DOUBLES_EQUAL(ewma->Rate(), expectedValue, EPS);
- ElapseMinute(*ewma);
- }
- }
-
- Y_UNIT_TEST(FiveMinutes) {
+ ewma->Update(3);
+ ewma->Tick();
+
+ TVector<double> expectedValues {
+ 0.6,
+ 0.22072766,
+ 0.08120117,
+ 0.02987224,
+ 0.01098938,
+ 0.00404277,
+ 0.00148725,
+ 0.00054713,
+ 0.00020128,
+ 0.00007405,
+ 0.00002724,
+ 0.00001002,
+ 0.00000369,
+ 0.00000136,
+ 0.00000050,
+ 0.00000018,
+ };
+
+ for (auto expectedValue : expectedValues) {
+ UNIT_ASSERT_DOUBLES_EQUAL(ewma->Rate(), expectedValue, EPS);
+ ElapseMinute(*ewma);
+ }
+ }
+
+ Y_UNIT_TEST(FiveMinutes) {
TGauge gauge;
-
+
auto ewma = FiveMinuteEwma(&gauge);
- ewma->Update(3);
- ewma->Tick();
-
- TVector<double> expectedValues {
- 0.6,
- 0.49123845,
- 0.40219203,
- 0.32928698,
- 0.26959738,
- 0.22072766,
- 0.18071653,
- 0.14795818,
- 0.12113791,
- 0.09917933,
- 0.08120117,
- 0.06648190,
- 0.05443077,
- 0.04456415,
- 0.03648604,
- 0.02987224,
- };
-
- for (auto expectedValue : expectedValues) {
- UNIT_ASSERT_DOUBLES_EQUAL(ewma->Rate(), expectedValue, EPS);
- ElapseMinute(*ewma);
- }
- }
-
- Y_UNIT_TEST(FiveteenMinutes) {
+ ewma->Update(3);
+ ewma->Tick();
+
+ TVector<double> expectedValues {
+ 0.6,
+ 0.49123845,
+ 0.40219203,
+ 0.32928698,
+ 0.26959738,
+ 0.22072766,
+ 0.18071653,
+ 0.14795818,
+ 0.12113791,
+ 0.09917933,
+ 0.08120117,
+ 0.06648190,
+ 0.05443077,
+ 0.04456415,
+ 0.03648604,
+ 0.02987224,
+ };
+
+ for (auto expectedValue : expectedValues) {
+ UNIT_ASSERT_DOUBLES_EQUAL(ewma->Rate(), expectedValue, EPS);
+ ElapseMinute(*ewma);
+ }
+ }
+
+ Y_UNIT_TEST(FiveteenMinutes) {
TGauge gauge;
-
+
auto ewma = FiveteenMinuteEwma(&gauge);
- ewma->Update(3);
- ewma->Tick();
-
- TVector<double> expectedValues {
- 0.6,
- 0.56130419,
- 0.52510399,
- 0.49123845,
- 0.45955700,
- 0.42991879,
- 0.40219203,
- 0.37625345,
- 0.35198773,
- 0.32928698,
- 0.30805027,
- 0.28818318,
- 0.26959738,
- 0.25221023,
- 0.23594443,
- 0.22072766,
- };
-
- for (auto expectedValue : expectedValues) {
- UNIT_ASSERT_DOUBLES_EQUAL(ewma->Rate(), expectedValue, EPS);
- ElapseMinute(*ewma);
- }
- }
-};
+ ewma->Update(3);
+ ewma->Tick();
+
+ TVector<double> expectedValues {
+ 0.6,
+ 0.56130419,
+ 0.52510399,
+ 0.49123845,
+ 0.45955700,
+ 0.42991879,
+ 0.40219203,
+ 0.37625345,
+ 0.35198773,
+ 0.32928698,
+ 0.30805027,
+ 0.28818318,
+ 0.26959738,
+ 0.25221023,
+ 0.23594443,
+ 0.22072766,
+ };
+
+ for (auto expectedValue : expectedValues) {
+ UNIT_ASSERT_DOUBLES_EQUAL(ewma->Rate(), expectedValue, EPS);
+ ElapseMinute(*ewma);
+ }
+ }
+};