log_histogram_collector_ut.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "log_histogram_collector.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. Y_UNIT_TEST_SUITE(LogHistogramCollector) {
  4. Y_UNIT_TEST(ExtendUpEmpty) {
  5. NMonitoring::TLogHistogramCollector collector(-1);
  6. collector.Collect(4.1944122207138854e+17);
  7. auto s = collector.Snapshot();
  8. UNIT_ASSERT_EQUAL(s->ZerosCount(), 0);
  9. UNIT_ASSERT_EQUAL(s->StartPower(), 1);
  10. UNIT_ASSERT_EQUAL(s->Count(), 100);
  11. UNIT_ASSERT_EQUAL(s->Bucket(s->Count() - 1), 1);
  12. }
  13. Y_UNIT_TEST(ExtendUpNonEmpty) {
  14. NMonitoring::TLogHistogramCollector collector(-1);
  15. collector.Collect(0.0);
  16. collector.Collect(1/(1.5*1.5*1.5));
  17. collector.Collect(1/1.5);
  18. auto s = collector.Snapshot();
  19. UNIT_ASSERT_EQUAL(s->ZerosCount(), 1);
  20. UNIT_ASSERT_EQUAL(s->StartPower(), -4);
  21. UNIT_ASSERT_EQUAL(s->Count(), 3);
  22. UNIT_ASSERT_EQUAL(s->Bucket(1), 1);
  23. UNIT_ASSERT_EQUAL(s->Bucket(2), 1);
  24. collector.Collect(4.1944122207138854e+17);
  25. s = collector.Snapshot();
  26. UNIT_ASSERT_EQUAL(s->ZerosCount(), 1);
  27. UNIT_ASSERT_EQUAL(s->StartPower(), 1);
  28. UNIT_ASSERT_EQUAL(s->Count(), 100);
  29. UNIT_ASSERT_EQUAL(s->Bucket(0), 2);
  30. UNIT_ASSERT_EQUAL(s->Bucket(99), 1);
  31. }
  32. }