userver: utils::statistics::BusyMarker Class Reference
Loading...
Searching...
No Matches
utils::statistics::BusyMarker Class Referencefinal

#include <userver/utils/statistics/busy.hpp>

Detailed Description

A RAII-style guard to account code block execution time in utils::statistics::BusyStorage. Aware of recursive invocations in the same thread.

EXPECT_FLOAT_EQ(0, storage.GetCurrentLoad());
{
if (some_heavy_task_that_takes_1s()) {
some_heavy_task_that_takes_3s();
// 4 seconds out of 5 were consumed -> 80%
EXPECT_FLOAT_EQ(0.8, storage.GetCurrentLoad());
}
}
EXPECT_LE(0.2, storage.GetCurrentLoad());
sleep_for_more_than_5s();
// No workload measured in last 5 seconds
EXPECT_FLOAT_EQ(0, storage.GetCurrentLoad());

Definition at line 52 of file busy.hpp.

Public Member Functions

 BusyMarker (BusyStorage &storage)
 
 BusyMarker (const BusyMarker &)=delete
 
BusyMarkeroperator= (const BusyMarker &)=delete
 

Constructor & Destructor Documentation

◆ BusyMarker()

utils::statistics::BusyMarker::BusyMarker ( BusyStorage & storage)
inline

Definition at line 54 of file busy.hpp.

◆ ~BusyMarker()

utils::statistics::BusyMarker::~BusyMarker ( )
inline

Definition at line 59 of file busy.hpp.


The documentation for this class was generated from the following file: