![]() |
MySQL 9.2.0
Source Code Documentation
|
Class that encodes how much time we waited for something. More...
#include <time_based_metric.h>
Public Member Functions | |
Time_based_metric (bool manual_counting=false) | |
Constructor that allows you to define counting as being manual. More... | |
Time_based_metric & | operator= (const Time_based_metric &other) |
Copy assignment operator. More... | |
Time_based_metric & | operator= (const Time_based_metric_interface &other) |
Assignment operator for the interface. More... | |
Time_based_metric (const Time_based_metric &)=delete | |
Deleted copy constructor, move constructor, move assignment operator. More... | |
Time_based_metric (Time_based_metric &&)=delete | |
Time_based_metric & | operator= (Time_based_metric &&)=delete |
~Time_based_metric () override=default | |
Default destuctor. More... | |
void | reset () override |
Resets the counter and summed time to 0. More... | |
int64_t | get_time () const override |
Returns the time waited across all executions of the start/stop methods. More... | |
void | increment_counter () override |
Increment the counter. More... | |
int64_t | get_count () const override |
Returns the number of time we waited on give spot. More... | |
![]() | |
virtual | ~Time_based_metric_interface ()=default |
auto | time_scope () |
Start the timer, and return an object that will stop the timer when it is deleted. More... | |
Protected Member Functions | |
void | start_timer () override |
Starts the timer. More... | |
void | stop_timer () override |
Stops the timer. More... | |
Static Private Member Functions | |
static int64_t | now () |
Helper to get current time. More... | |
Private Attributes | |
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.
|
explicit |
Constructor that allows you to define counting as being manual.
manual_counting | shall count be automatic on start_timer or not (default false) |
|
delete |
Deleted copy constructor, move constructor, move assignment operator.
|
delete |
|
overridedefault |
Default destuctor.
|
overridevirtual |
Returns the number of time we waited on give spot.
Implements Time_based_metric_interface.
|
overridevirtual |
Returns the time waited across all executions of the start/stop methods.
Implements Time_based_metric_interface.
|
overridevirtual |
Increment the counter.
This is only allowed if the constructor was called using manual_counting=1. Otherwise, an assertion is raised.
Implements Time_based_metric_interface.
|
staticprivate |
Helper to get current time.
Time_based_metric & Time_based_metric::operator= | ( | const Time_based_metric & | other | ) |
Copy assignment operator.
other | the object that is copied |
Time_based_metric & Time_based_metric::operator= | ( | const Time_based_metric_interface & | other | ) |
Assignment operator for the interface.
other | the object that is copied |
|
delete |
|
overridevirtual |
Resets the counter and summed time to 0.
Implements Time_based_metric_interface.
|
overrideprotectedvirtual |
Starts the timer.
Implements Time_based_metric_interface.
|
overrideprotectedvirtual |
Stops the timer.
Implements Time_based_metric_interface.
|
private |
The number of times we waited.
|
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.
|
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