aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp
diff options
context:
space:
mode:
authorVladislav Kuznetsov <va.kuznecov@physics.msu.ru>2022-02-10 16:46:54 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:54 +0300
commit3cbae1ba94bff7a82ee848c3e9b2cebd96a69dd5 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp
parentde20f5598f0832a6e646f61b4feca942c00da928 (diff)
downloadydb-3cbae1ba94bff7a82ee848c3e9b2cebd96a69dd5.tar.gz
Restoring authorship annotation for Vladislav Kuznetsov <va.kuznecov@physics.msu.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp')
-rw-r--r--library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp b/library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp
index b30cf36328..6c8bb54ec9 100644
--- a/library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp
+++ b/library/cpp/monlib/dynamic_counters/percentile/percentile_ut.cpp
@@ -5,58 +5,58 @@ using namespace NMonitoring;
Y_UNIT_TEST_SUITE(PercentileTest) {
-template<size_t A, size_t B, size_t B_BEGIN>
-void printSizeAndLimit() {
- using TPerc = TPercentileTrackerLg<A, B, 15>;
- Cout << "TPercentileTrackerLg<" << A << ", " << B << ", 15>"
- << "; sizeof# " << LeftPad(HumanReadableSize(sizeof(TPerc), SF_BYTES), 7)
- << "; max_granularity# " << LeftPad(HumanReadableSize(TPerc::MAX_GRANULARITY, SF_QUANTITY), 5)
- << "; limit# " << LeftPad(HumanReadableSize(TPerc::TRACKER_LIMIT , SF_QUANTITY), 5) << Endl;
- if constexpr (B > 1) {
- printSizeAndLimit<A, B - 1, B_BEGIN>();
- } else if constexpr (A > 1) {
- Cout << Endl;
- printSizeAndLimit<A - 1, B_BEGIN, B_BEGIN>();
- }
-}
-
- Y_UNIT_TEST(PrintTrackerLgSizeAndLimits) {
- printSizeAndLimit<10, 5, 5>();
- }
-
- Y_UNIT_TEST(TrackerLimitTest) {
- {
- using TPerc = TPercentileTrackerLg<1, 0, 1>;
- TPerc tracker;
- tracker.Increment(Max<size_t>());
- UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
- }
- {
- using TPerc = TPercentileTrackerLg<1, 1, 1>;
- TPerc tracker;
- tracker.Increment(Max<size_t>());
- UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
- }
- {
- using TPerc = TPercentileTrackerLg<1, 5, 1>;
- TPerc tracker;
- tracker.Increment(Max<size_t>());
- UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
- }
- {
- using TPerc = TPercentileTrackerLg<2, 1, 1>;
- TPerc tracker;
- tracker.Increment(Max<size_t>());
- UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
- }
- {
- using TPerc = TPercentileTrackerLg<5, 4, 1>;
- TPerc tracker;
- tracker.Increment(Max<size_t>());
- UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
- }
- }
-
+template<size_t A, size_t B, size_t B_BEGIN>
+void printSizeAndLimit() {
+ using TPerc = TPercentileTrackerLg<A, B, 15>;
+ Cout << "TPercentileTrackerLg<" << A << ", " << B << ", 15>"
+ << "; sizeof# " << LeftPad(HumanReadableSize(sizeof(TPerc), SF_BYTES), 7)
+ << "; max_granularity# " << LeftPad(HumanReadableSize(TPerc::MAX_GRANULARITY, SF_QUANTITY), 5)
+ << "; limit# " << LeftPad(HumanReadableSize(TPerc::TRACKER_LIMIT , SF_QUANTITY), 5) << Endl;
+ if constexpr (B > 1) {
+ printSizeAndLimit<A, B - 1, B_BEGIN>();
+ } else if constexpr (A > 1) {
+ Cout << Endl;
+ printSizeAndLimit<A - 1, B_BEGIN, B_BEGIN>();
+ }
+}
+
+ Y_UNIT_TEST(PrintTrackerLgSizeAndLimits) {
+ printSizeAndLimit<10, 5, 5>();
+ }
+
+ Y_UNIT_TEST(TrackerLimitTest) {
+ {
+ using TPerc = TPercentileTrackerLg<1, 0, 1>;
+ TPerc tracker;
+ tracker.Increment(Max<size_t>());
+ UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
+ }
+ {
+ using TPerc = TPercentileTrackerLg<1, 1, 1>;
+ TPerc tracker;
+ tracker.Increment(Max<size_t>());
+ UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
+ }
+ {
+ using TPerc = TPercentileTrackerLg<1, 5, 1>;
+ TPerc tracker;
+ tracker.Increment(Max<size_t>());
+ UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
+ }
+ {
+ using TPerc = TPercentileTrackerLg<2, 1, 1>;
+ TPerc tracker;
+ tracker.Increment(Max<size_t>());
+ UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
+ }
+ {
+ using TPerc = TPercentileTrackerLg<5, 4, 1>;
+ TPerc tracker;
+ tracker.Increment(Max<size_t>());
+ UNIT_ASSERT_EQUAL(TPerc::TRACKER_LIMIT, tracker.GetPercentile(1.0));
+ }
+ }
+
Y_UNIT_TEST(BucketIdxIfvsBucketIdxBinarySearch) {
for (size_t var = 0; var < 5; var++) {
if (var == 0) {