Thrill  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

Detailed Description

Class timer is a simple stop watch timer.

It uses the timestamp() function to get the current time when start() is called. Then, after some processing, the function stop() functions can be called, or seconds() and other accessors can be called directly.

Definition at line 50 of file timer.hpp.

#include <timer.hpp>

Public Member Functions

 timer (bool start_immediately=false)
 initialize and optionally immediately start the timer More...
 
double mseconds () const
 return currently accumulated time in milliseconds More...
 
timeroperator+= (const timer &tm)
 accumulate elapsed time from another timer More...
 
void reset ()
 return accumulated time More...
 
double seconds () const
 return currently accumulated time in seconds (as double) More...
 
void start ()
 start timer More...
 
void stop ()
 stop timer More...
 
double useconds () const
 return currently accumulated time in microseconds More...
 

Static Public Attributes

static const bool is_real = true
 boolean indicating that this class does real timing More...
 

Static Private Member Functions

static double timestamp ()
 return current timestamp More...
 

Private Attributes

double accumulated
 total accumulated time in seconds. More...
 
double last_clock
 last start time of the stopwatch More...
 
std::mutex mutex_accumulated
 guard accumulated More...
 
bool running
 boolean whether the stopwatch timer is currently running More...
 

Friends

std::ostream & operator<< (std::ostream &os, const timer &t)
 direct <<-operator for ostream. Can be used for printing with std::cout. More...
 

Constructor & Destructor Documentation

◆ timer()

timer ( bool  start_immediately = false)
inlineexplicit

initialize and optionally immediately start the timer

Definition at line 75 of file timer.hpp.

References timer::start().

Member Function Documentation

◆ mseconds()

double mseconds ( ) const
inline

return currently accumulated time in milliseconds

Definition at line 107 of file timer.hpp.

References timer::timestamp().

◆ operator+=()

timer& operator+= ( const timer tm)
inline

accumulate elapsed time from another timer

Definition at line 144 of file timer.hpp.

References examples::select::delta, and timer::seconds().

◆ reset()

void reset ( )
inline

return accumulated time

Definition at line 99 of file timer.hpp.

References timer::timestamp().

◆ seconds()

double seconds ( ) const
inline

return currently accumulated time in seconds (as double)

Definition at line 131 of file timer.hpp.

References examples::select::delta, timer::last_clock, and timer::timestamp().

Referenced by timer::operator+=(), and scoped_print_timer::~scoped_print_timer().

◆ start()

void start ( )
inline

start timer

Definition at line 82 of file timer.hpp.

References timer::timestamp().

Referenced by timer::timer().

◆ stop()

void stop ( )
inline

stop timer

Definition at line 89 of file timer.hpp.

References examples::select::delta, timer::last_clock, and timer::timestamp().

◆ timestamp()

static double timestamp ( )
inlinestaticprivate

return current timestamp

Definition at line 62 of file timer.hpp.

References foxxll::timestamp().

Referenced by timer::mseconds(), timer::reset(), timer::seconds(), timer::start(), timer::stop(), and timer::useconds().

◆ useconds()

double useconds ( ) const
inline

return currently accumulated time in microseconds

Definition at line 118 of file timer.hpp.

References examples::select::delta, timer::last_clock, and timer::timestamp().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const timer t 
)
friend

direct <<-operator for ostream. Can be used for printing with std::cout.

Definition at line 154 of file timer.hpp.

Member Data Documentation

◆ accumulated

double accumulated
private

total accumulated time in seconds.

Definition at line 56 of file timer.hpp.

◆ is_real

const bool is_real = true
static

boolean indicating that this class does real timing

Definition at line 72 of file timer.hpp.

◆ last_clock

double last_clock
private

last start time of the stopwatch

Definition at line 59 of file timer.hpp.

Referenced by timer::seconds(), timer::stop(), and timer::useconds().

◆ mutex_accumulated

std::mutex mutex_accumulated
mutableprivate

guard accumulated

Definition at line 68 of file timer.hpp.

◆ running

bool running
private

boolean whether the stopwatch timer is currently running

Definition at line 53 of file timer.hpp.


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