Class that encodes how much time we waited for something.
More...
#include <time_based_metric.h>
|
static int64_t | now () |
| Helper to get current time. More...
|
|
|
std::atomic< int64_t > | m_time {0} |
| The total nanoseconds of all completed waits, minus the absolute start time of an ongoing wait, if any. More...
|
|
std::atomic< int64_t > | m_count {0} |
| The number of times we waited. More...
|
|
bool | m_manual_counting {false} |
| If false, the counter is incremented automatically by start_time, and the caller must not invoke increment_counter. More...
|
|
Class that encodes how much time we waited for something.
◆ Time_based_metric() [1/3]
Time_based_metric::Time_based_metric |
( |
bool |
manual_counting = false | ) |
|
|
explicit |
Constructor that allows you to define counting as being manual.
- Parameters
-
manual_counting | shall count be automatic on start_timer or not (default false) |
◆ Time_based_metric() [2/3]
Deleted copy constructor, move constructor, move assignment operator.
◆ Time_based_metric() [3/3]
◆ ~Time_based_metric()
Time_based_metric::~Time_based_metric |
( |
| ) |
|
|
overridedefault |
◆ get_count()
int64_t Time_based_metric::get_count |
( |
| ) |
const |
|
overridevirtual |
◆ get_sum_time_elapsed()
int64_t Time_based_metric::get_sum_time_elapsed |
( |
| ) |
const |
|
overridevirtual |
Returns the time waited across all executions of the start/stop methods.
- Returns
- The total time waited
Implements Time_based_metric_interface.
◆ increment_counter()
void Time_based_metric::increment_counter |
( |
| ) |
|
|
overridevirtual |
◆ now()
int64_t Time_based_metric::now |
( |
| ) |
|
|
staticprivate |
Helper to get current time.
- Returns
- Current time since the epoch for steady_clock, in nanoseconds.
◆ operator=() [1/2]
Assignment operator.
- Parameters
-
other | the object that is copied |
- Returns
- this object
◆ operator=() [2/2]
◆ reset()
void Time_based_metric::reset |
( |
| ) |
|
|
overridevirtual |
◆ start_timer()
void Time_based_metric::start_timer |
( |
| ) |
|
|
overridevirtual |
◆ stop_timer()
void Time_based_metric::stop_timer |
( |
| ) |
|
|
overridevirtual |
◆ m_count
std::atomic<int64_t> Time_based_metric::m_count {0} |
|
private |
The number of times we waited.
◆ m_manual_counting
bool Time_based_metric::m_manual_counting {false} |
|
private |
If false, the counter is incremented automatically by start_time, and the caller must not invoke increment_counter.
If true, the counter is not incremented by start_time, so the caller has to invoke increment_counter.
◆ m_time
std::atomic<int64_t> Time_based_metric::m_time {0} |
|
private |
The total nanoseconds of all completed waits, minus the absolute start time of an ongoing wait, if any.
If there is no ongoing wait, this is nonnegative and is the correct metric. If there is an ongoing wait, this is negative, and the correct value is given by adding the current time to it: result = sum_of_completed_waits + current_time - start_of_current_wait
The documentation for this class was generated from the following files: