MySQL 8.0.39
Source Code Documentation
ib::Timer Class Reference

For measuring time elapsed. More...

#include <ut0ut.h>

Public Types

using SC = std::chrono::steady_clock
 

Public Member Functions

 Timer () noexcept
 Constructor. More...
 
void reset ()
 Reset the timer to the current time. More...
 
template<typename T = std::chrono::milliseconds>
int64_t elapsed () const noexcept
 

Private Attributes

SC::time_point m_start
 High resolution timer instance used for timimg. More...
 

Friends

template<typename T , typename Traits >
std::basic_ostream< T, Traits > & operator<< (std::basic_ostream< T, Traits > &out, const Timer &timer) noexcept
 Print time elapsed since last reset (in milliseconds) to the stream. More...
 

Detailed Description

For measuring time elapsed.

Since std::chrono::high_resolution_clock may be influenced by a change in system time, it might not be steady. So we use std::chrono::steady_clock for elapsed time.

Member Typedef Documentation

◆ SC

using ib::Timer::SC = std::chrono::steady_clock

Constructor & Destructor Documentation

◆ Timer()

ib::Timer::Timer ( )
inlinenoexcept

Constructor.

Starts/resets the timer to the current time.

Member Function Documentation

◆ elapsed()

template<typename T = std::chrono::milliseconds>
int64_t ib::Timer::elapsed ( ) const
inlinenoexcept
Returns
the time elapsed in milliseconds.

◆ reset()

void ib::Timer::reset ( void  )
inline

Reset the timer to the current time.

Friends And Related Function Documentation

◆ operator<<

template<typename T , typename Traits >
std::basic_ostream< T, Traits > & operator<< ( std::basic_ostream< T, Traits > &  out,
const Timer timer 
)
friend

Print time elapsed since last reset (in milliseconds) to the stream.

Parameters
[in,out]outStream to write to.
[in]timerTimer to write to the stream.
Returns
stream instance that was passed in.

Member Data Documentation

◆ m_start

SC::time_point ib::Timer::m_start
private

High resolution timer instance used for timimg.


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