diff options
| author | jon2205 <[email protected]> | 2022-02-10 16:50:59 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:50:59 +0300 | 
| commit | 1cbb079ecb3328b501da4e4bdb362ef2b91ad2bb (patch) | |
| tree | 9cd683cacc394d43b524657469696f43c90f2824 /library/cpp/monlib/counters | |
| parent | 886713d680d0ec0e1d8847528a7a6e5fa825c58d (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/counters')
| -rw-r--r-- | library/cpp/monlib/counters/timer.h | 2 | ||||
| -rw-r--r-- | library/cpp/monlib/counters/timer_ut.cpp | 48 | 
2 files changed, 25 insertions, 25 deletions
| diff --git a/library/cpp/monlib/counters/timer.h b/library/cpp/monlib/counters/timer.h index 03dfb35337f..d64606b2a08 100644 --- a/library/cpp/monlib/counters/timer.h +++ b/library/cpp/monlib/counters/timer.h @@ -166,7 +166,7 @@ namespace NMonitoring {                  (*Callback_)(duration);              }              Timer_->RecordValue(duration); -        } +        }       private:          TTimer* Timer_; diff --git a/library/cpp/monlib/counters/timer_ut.cpp b/library/cpp/monlib/counters/timer_ut.cpp index c5cd07e89d5..207006fc3af 100644 --- a/library/cpp/monlib/counters/timer_ut.cpp +++ b/library/cpp/monlib/counters/timer_ut.cpp @@ -5,17 +5,17 @@  using namespace NMonitoring;  using namespace std::literals::chrono_literals; -class TCallback { -public: +class TCallback {  +public:       explicit TCallback(int value)          : Value_(value){}; -    void operator()(std::chrono::high_resolution_clock::duration duration) { -        Value_ = duration.count(); -    }; - -    int Value_; -}; - +    void operator()(std::chrono::high_resolution_clock::duration duration) {  +        Value_ = duration.count();  +    };  +  +    int Value_;  +};  +   Y_UNIT_TEST_SUITE(TTimerTest) {      Y_UNIT_TEST(RecordValue) {          TTimerNs timerNs(1ns, 1s); @@ -62,20 +62,20 @@ Y_UNIT_TEST_SUITE(TTimerTest) {          UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count());          UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6);      } - +       Y_UNIT_TEST(TimerScopeWithCallback) { -        TCallback callback(0); -        TTimerUs timer(1us, 1000s); -        { -            TTimerScope<TTimerUs, TCallback> scope(&timer, &callback); -            Sleep(TDuration::MilliSeconds(10)); -        } -        THistogramSnapshot snapshot; -        timer.TakeSnapshot(&snapshot); - -        UNIT_ASSERT(snapshot.Min > std::chrono::microseconds(10ms).count()); -        UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count()); -        UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); -        UNIT_ASSERT(callback.Value_ > std::chrono::microseconds(10ms).count()); -    } +        TCallback callback(0);  +        TTimerUs timer(1us, 1000s);  +        {  +            TTimerScope<TTimerUs, TCallback> scope(&timer, &callback);  +            Sleep(TDuration::MilliSeconds(10));  +        }  +        THistogramSnapshot snapshot;  +        timer.TakeSnapshot(&snapshot);  +  +        UNIT_ASSERT(snapshot.Min > std::chrono::microseconds(10ms).count());  +        UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count());  +        UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6);  +        UNIT_ASSERT(callback.Value_ > std::chrono::microseconds(10ms).count());  +    }   } | 
