diff options
author | msherbakov <msherbakov@yandex-team.ru> | 2022-02-10 16:49:16 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:16 +0300 |
commit | c224a621661ddd69699f9476922eb316607ef57e (patch) | |
tree | 33f4d878aa0a9faa964005e06bfab0272313aa71 /library/cpp/monlib/metrics/timer_ut.cpp | |
parent | 29d0b2eeae154d04156e0698067c0c21a97ea61d (diff) | |
download | ydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz |
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/timer_ut.cpp')
-rw-r--r-- | library/cpp/monlib/metrics/timer_ut.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/library/cpp/monlib/metrics/timer_ut.cpp b/library/cpp/monlib/metrics/timer_ut.cpp index c244a8c9e1..1786f12d17 100644 --- a/library/cpp/monlib/metrics/timer_ut.cpp +++ b/library/cpp/monlib/metrics/timer_ut.cpp @@ -5,7 +5,7 @@ #include <library/cpp/threading/future/future.h> using namespace NMonitoring; -using namespace NThreading; +using namespace NThreading; Y_UNIT_TEST_SUITE(TTimerTest) { @@ -115,43 +115,43 @@ Y_UNIT_TEST_SUITE(TTimerTest) { } assertHistogram({1, 1, 0, 0}, histogram.TakeSnapshot()); } - - Y_UNIT_TEST(Moving) { - TTestClock::TimePoint = TTestClock::time_point::min(); - + + Y_UNIT_TEST(Moving) { + TTestClock::TimePoint = TTestClock::time_point::min(); + TCounter counter(0); - { + { TMetricTimerScope<TCounter, milliseconds, TTestClock> t{&counter}; - [tt = std::move(t)] { - TTestClock::TimePoint += milliseconds(5); - Y_UNUSED(tt); - }(); - - TTestClock::TimePoint += milliseconds(10); - } - - UNIT_ASSERT_EQUAL(counter.Get(), 5); - } - - Y_UNIT_TEST(MovingIntoApply) { - TTestClock::TimePoint = TTestClock::time_point::min(); - auto pool = CreateThreadPool(1); - + [tt = std::move(t)] { + TTestClock::TimePoint += milliseconds(5); + Y_UNUSED(tt); + }(); + + TTestClock::TimePoint += milliseconds(10); + } + + UNIT_ASSERT_EQUAL(counter.Get(), 5); + } + + Y_UNIT_TEST(MovingIntoApply) { + TTestClock::TimePoint = TTestClock::time_point::min(); + auto pool = CreateThreadPool(1); + TCounter counter(0); - { + { TFutureFriendlyTimer<TCounter, milliseconds, TTestClock> t{&counter}; - - auto f = Async([=] { - return; - }, *pool).Apply([tt = t] (auto) { - TTestClock::TimePoint += milliseconds(5); - tt.Record(); - }); - - f.Wait(); - TTestClock::TimePoint += milliseconds(10); - } - - UNIT_ASSERT_EQUAL(counter.Get(), 5); - } + + auto f = Async([=] { + return; + }, *pool).Apply([tt = t] (auto) { + TTestClock::TimePoint += milliseconds(5); + tt.Record(); + }); + + f.Wait(); + TTestClock::TimePoint += milliseconds(10); + } + + UNIT_ASSERT_EQUAL(counter.Get(), 5); + } } |