LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
lbann::Timer Class Reference

An exceedingly simple duration calculator. More...

#include <timer.hpp>

Public Types

using ClockType = std::chrono::steady_clock
 The clock used for counting. More...
 
using TimePoint = typename ClockType::time_point
 Simplifying typedef. More...
 

Public Member Functions

 Timer ()=default
 
 ~Timer () noexcept=default
 
 Timer (Timer const &)=delete
 
Timeroperator= (Timer const &)=delete
 
 Timer (Timer &&)=default
 
Timeroperator= (Timer &&)=default
 
void start () noexcept
 Start counting time. More...
 
double stop () noexcept
 Get the total elapsed time in seconds. More...
 
double check () const noexcept
 Get the current elapsed time (seconds) without stopping. More...
 
void reset () noexcept
 Clear any internal state in the timer. More...
 
bool running () const noexcept
 Check if the timer is running. More...
 

Private Attributes

TimePoint m_start
 

Detailed Description

An exceedingly simple duration calculator.

This clock does not have a notion of "pause and restart". Calling check() will not stop the counter; calling stop() will clear the counter. Calling start() on a running timer will reset the clock to zero.

Definition at line 52 of file utils/timer.hpp.

Member Typedef Documentation

◆ ClockType

using lbann::Timer::ClockType = std::chrono::steady_clock

The clock used for counting.

Per guidance from cppreference, this should be the steady clock for measuring durations. The high-res clock can be unstable. (Source)

Definition at line 61 of file utils/timer.hpp.

◆ TimePoint

using lbann::Timer::TimePoint = typename ClockType::time_point

Simplifying typedef.

Definition at line 63 of file utils/timer.hpp.

Constructor & Destructor Documentation

◆ Timer() [1/3]

lbann::Timer::Timer ( )
default

◆ ~Timer()

lbann::Timer::~Timer ( )
defaultnoexcept

◆ Timer() [2/3]

lbann::Timer::Timer ( Timer const &  )
delete

◆ Timer() [3/3]

lbann::Timer::Timer ( Timer &&  )
default

Member Function Documentation

◆ check()

double lbann::Timer::check ( ) const
inlinenoexcept

Get the current elapsed time (seconds) without stopping.

Definition at line 97 of file utils/timer.hpp.

Here is the caller graph for this function:

◆ operator=() [1/2]

Timer& lbann::Timer::operator= ( Timer const &  )
delete

◆ operator=() [2/2]

Timer& lbann::Timer::operator= ( Timer &&  )
default

◆ reset()

void lbann::Timer::reset ( )
inlinenoexcept

Clear any internal state in the timer.

Postcondition
running() returns false; check() and stop() return 0.

Definition at line 106 of file utils/timer.hpp.

Here is the caller graph for this function:

◆ running()

bool lbann::Timer::running ( ) const
inlinenoexcept

Check if the timer is running.

Definition at line 109 of file utils/timer.hpp.

Here is the caller graph for this function:

◆ start()

void lbann::Timer::start ( )
inlinenoexcept

Start counting time.

If the clock is already running, this will restart the counter.

Postcondition
running() returns true; stop() or check() will return a positive value.

Definition at line 80 of file utils/timer.hpp.

Here is the caller graph for this function:

◆ stop()

double lbann::Timer::stop ( )
inlinenoexcept

Get the total elapsed time in seconds.

Resets the counter, so a subsequent call to stop() or check() without another start() will return 0.0.

Postcondition
running() returns false, as if reset() were called.

Definition at line 89 of file utils/timer.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_start

TimePoint lbann::Timer::m_start
private

Definition at line 112 of file utils/timer.hpp.


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