smats  0.0.1
Satisfability Modulo Arithmetic Theories Symbols
Loading...
Searching...
No Matches
smats::TimerBase< T > Class Template Reference

#include <timer.h>

Public Types

using clock = T
 
typedef clock::duration duration
 
typedef clock::time_point time_point
 

Public Member Functions

 TimerBase ()
 
void start ()
 
void pause ()
 
void resume ()
 
bool is_running () const
 
duration elapsed () const
 
std::chrono::duration< double >::rep seconds () const
 
TimerBase< T > & operator+= (const TimerBase< T > &other)
 
TimerBase< T > operator+ (const TimerBase< T > &other) const
 

Protected Member Functions

time_point now () const
 

Private Attributes

bool running_ {false}
 Whether the timer is running or not.
 
time_point last_start_ {}
 Last time_point when the timer is started or resumed.
 
duration elapsed_ {}
 Elapsed time so far. This doesn't include the current fragment if it is running.
 

Detailed Description

template<typename T>
class smats::TimerBase< T >

Simple timer class to evaluate the performance of the software.

Constructor & Destructor Documentation

◆ TimerBase()

template<class T >
smats::TimerBase< T >::TimerBase ( )

Construct a new timer base object.

Member Function Documentation

◆ elapsed()

template<class T >
TimerBase< T >::duration smats::TimerBase< T >::elapsed ( ) const
nodiscard

Get read-only access to the duration of elapsed time of the timer.

Returns
duration of elapsed time of the timer

◆ is_running()

template<class T >
bool smats::TimerBase< T >::is_running ( ) const
nodiscard

Check whether the timer is running.

Returns
true if the timer is running
false if the timer is not running

◆ now()

template<typename T >
time_point smats::TimerBase< T >::now ( ) const
inlinenodiscardprotected

Get read-only access to the current instant of the timer.

Returns
current instant of the timer

◆ pause()

template<class T >
void smats::TimerBase< T >::pause ( )

Pause the timer.

If the timer is not running, this function does nothing.

◆ resume()

template<class T >
void smats::TimerBase< T >::resume ( )

Resume the timer.

If the timer is not running, this function does nothing.

◆ seconds()

template<class T >
std::chrono::duration< double >::rep smats::TimerBase< T >::seconds ( ) const
nodiscard

Get read-only access to the number elapsed seconds of the timer.

Returns
number elapsed seconds of the timer

◆ start()

template<class T >
void smats::TimerBase< T >::start ( )

Start the timer.

The timer is reset to zero.


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