#include <userver/utils/statistics/busy.hpp >
Measure how much time we've spent in work recently in percents that supports recirsive starts. Use utils::statistics::BusyMarker for RAII time measures.
EXPECT_FLOAT_EQ(0, storage.GetCurrentLoad());
{
if (some_heavy_task_that_takes_1s()) {
some_heavy_task_that_takes_3s();
EXPECT_FLOAT_EQ(0.8, storage.GetCurrentLoad());
}
}
EXPECT_LE(0.2, storage.GetCurrentLoad());
sleep_for_more_than_5s();
EXPECT_FLOAT_EQ(0, storage.GetCurrentLoad());
Definition at line 19 of file busy.hpp .
using Duration = std::chrono::steady_clock::duration
BusyStorage (Duration epoch_duration, Duration history_period)
double GetCurrentLoad () const
Safe to read concurrently with calling StartWork() and StopWork()
void StartWork ()
Starts the time measure, if it was not already started.
void StopWork () noexcept
bool IsAlreadyStarted () const noexcept
Returns true if the time measure is active.
◆ Duration
using utils::statistics::BusyStorage::Duration = std::chrono::steady_clock::duration
◆ StopWork()
void utils::statistics::BusyStorage::StopWork
(
)
noexcept
The documentation for this class was generated from the following file: