Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 ( 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

double mseconds ( ) const
inline

return currently accumulated time in milliseconds

Definition at line 107 of file timer.hpp.

References timer::accumulated, timer::last_clock, timer::mutex_accumulated, timer::running, and timer::timestamp().

timer& operator+= ( const timer tm)
inline

accumulate elapsed time from another timer

Definition at line 144 of file timer.hpp.

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

void reset ( )
inline

return accumulated time

Definition at line 99 of file timer.hpp.

References timer::accumulated, timer::last_clock, timer::mutex_accumulated, and timer::timestamp().

double seconds ( ) const
inline

return currently accumulated time in seconds (as double)

Definition at line 131 of file timer.hpp.

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

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

void start ( )
inline

start timer

Definition at line 82 of file timer.hpp.

References timer::last_clock, timer::running, and timer::timestamp().

Referenced by timer::timer().

void stop ( )
inline
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().

double useconds ( ) const
inline

return currently accumulated time in microseconds

Definition at line 118 of file timer.hpp.

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

Friends And Related Function Documentation

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

double accumulated
private

total accumulated time in seconds.

Definition at line 56 of file timer.hpp.

Referenced by timer::mseconds(), timer::operator+=(), timer::reset(), timer::seconds(), timer::stop(), and timer::useconds().

const bool is_real = true
static

boolean indicating that this class does real timing

Definition at line 72 of file timer.hpp.

double last_clock
private

last start time of the stopwatch

Definition at line 59 of file timer.hpp.

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

std::mutex mutex_accumulated
private

guard accumulated

Definition at line 68 of file timer.hpp.

Referenced by timer::mseconds(), timer::operator+=(), timer::reset(), timer::seconds(), timer::stop(), and timer::useconds().

bool running
private

boolean whether the stopwatch timer is currently running

Definition at line 53 of file timer.hpp.

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


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