Public Member Functions

 Timers ()
 Default to disabled. More...

 
std::atomic< bool > & Enabled ()
 Modify whether or not timing is enabled. More...

 
bool Enabled () const
 Get whether or not timing is enabled. More...

 
std::chrono::microseconds Get (const std::string &timerName)
 Returns a copy of the timer specified. More...

 
std::map< std::string, std::chrono::microseconds > GetAllTimers ()
 Returns a copy of all the timers used via this interface. More...

 
void Reset ()
 Reset the timers. More...

 
void Start (const std::string &timerName, const std::thread::id &threadId=std::thread::id())
 Initializes a timer, available like a normal value specified on the command line. More...

 
void Stop (const std::string &timerName, const std::thread::id &threadId=std::thread::id())
 Halts the timer, and replaces its value with the delta time from its start. More...

 
void StopAllTimers ()
 Stop all timers. More...

 

Static Public Member Functions

static std::string Print (const std::chrono::microseconds &totalDuration)
 Prints the specified timer. More...

 

Detailed Description

Definition at line 105 of file timers.hpp.

Constructor & Destructor Documentation

◆ Timers()

Timers ( )
inline

Default to disabled.

Definition at line 109 of file timers.hpp.

References Timer::Get(), Timer::GetAllTimers(), Timer::Start(), and Timer::Stop().

Member Function Documentation

◆ Enabled() [1/2]

std::atomic<bool>& Enabled ( )
inline

Modify whether or not timing is enabled.

Definition at line 165 of file timers.hpp.

Referenced by main().

◆ Enabled() [2/2]

bool Enabled ( ) const
inline

Get whether or not timing is enabled.

Definition at line 167 of file timers.hpp.

◆ Get()

std::chrono::microseconds Get ( const std::string &  timerName)

Returns a copy of the timer specified.

This contains the sum of the timing results for timers that have been stopped with this name.

Parameters
timerNameThe name of the timer in question.

◆ GetAllTimers()

std::map<std::string, std::chrono::microseconds> GetAllTimers ( )

Returns a copy of all the timers used via this interface.

Referenced by mlpack::bindings::cli::EndProgram().

◆ Print()

static std::string Print ( const std::chrono::microseconds &  totalDuration)
static

Prints the specified timer.

If it took longer than a minute to complete the timer will be displayed in days, hours, and minutes as well.

Parameters
timerNameThe number of microseconds to print.

Referenced by mlpack::bindings::cli::EndProgram().

◆ Reset()

void Reset ( )

Reset the timers.

This stops all running timers and removes them. Whether or not timing is enabled will not be changed.

◆ Start()

void Start ( const std::string &  timerName,
const std::thread::id &  threadId = std::thread::id() 
)

Initializes a timer, available like a normal value specified on the command line.

Timers are of type timeval. If a timer is started, then stopped, then re-started, then stopped, the final timer value will be the length of both runs of the timer.

Parameters
timerNameThe name of the timer in question.
threadIdId of the thread accessing the timer.

Referenced by main().

◆ Stop()

void Stop ( const std::string &  timerName,
const std::thread::id &  threadId = std::thread::id() 
)

Halts the timer, and replaces its value with the delta time from its start.

Parameters
timerNameThe name of the timer in question.
threadIdId of the thread accessing the timer.

Referenced by main().

◆ StopAllTimers()

void StopAllTimers ( )

Stop all timers.

Referenced by mlpack::bindings::cli::EndProgram().


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/core/util/timers.hpp