TBCI Numerical high perf. C++ Library  2.8.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
stopw_base Class Reference

base class for all the stop watches to minimize code duplication More...

#include <stopwatch.h>

Inheritance diagram for stopw_base:
Inheritance graph
[legend]

Public Member Functions

 stopw_base (const double tick, const double over=-1.0)
 c'tor More...
 
virtual ~stopw_base ()
 d'tor More...
 
double reset ()
 Resets the stopwatch. More...
 
void start ()
 Starts the stopwatch. More...
 
double stop ()
 Stops the stopwatch and returns total time (since last reset) More...
 
double stop_d ()
 Stops the stopwatch and returns time since last start / read. More...
 
double read ()
 Returns the total time without stopping the stopwatch (but resets the differential timer) More...
 
double read_d ()
 Returns the time since last read/start without stopping the stopwatch (but resets the differential timer) More...
 

Protected Member Functions

virtual double seconds () const
 Return the current time, to be overriden in derived classes. More...
 
double adv_stopwatch ()
 Advance the stopwatch, return diff, handle single overflows. More...
 

Protected Attributes

double last_time
 The last time we read/started/stopped the clock. More...
 
double total
 The total elapsed time since construction or reset. More...
 
const double secs_per_tick
 Used in seconds() to convert internal time to s. More...
 
const double overflow_secs
 If we overflow once, we miss this many seconds; We assume that internally long ints are used, i.e. More...
 
int running
 The status. More...
 

Detailed Description

base class for all the stop watches to minimize code duplication

Definition at line 86 of file stopwatch.h.

Constructor & Destructor Documentation

stopw_base::stopw_base ( const double  tick,
const double  over = -1.0 
)
inline

c'tor

Definition at line 127 of file stopwatch.h.

virtual stopw_base::~stopw_base ( )
inlinevirtual

d'tor

Definition at line 135 of file stopwatch.h.

Member Function Documentation

double stopw_base::adv_stopwatch ( )
inlineprotected

Advance the stopwatch, return diff, handle single overflows.

Definition at line 109 of file stopwatch.h.

References last_time, overflow_secs, seconds(), secs_per_tick, and total.

Referenced by read(), read_d(), start(), stop(), and stop_d().

double stopw_base::read ( )
inline

Returns the total time without stopping the stopwatch (but resets the differential timer)

Definition at line 173 of file stopwatch.h.

References adv_stopwatch(), running, and total.

double stopw_base::read_d ( )
inline

Returns the time since last read/start without stopping the stopwatch (but resets the differential timer)

Definition at line 181 of file stopwatch.h.

References adv_stopwatch(), and running.

double stopw_base::reset ( )
inline

Resets the stopwatch.

Definition at line 137 of file stopwatch.h.

References last_time, running, and total.

virtual double stopw_base::seconds ( ) const
inlineprotectedvirtual

Return the current time, to be overriden in derived classes.

Reimplemented in stopwatch_e, stopwatch_us, and stopwatch_u.

Definition at line 104 of file stopwatch.h.

References secs_per_tick.

Referenced by adv_stopwatch(), and start().

void stopw_base::start ( )
inline

Starts the stopwatch.

Definition at line 145 of file stopwatch.h.

References adv_stopwatch(), last_time, running, and seconds().

double stopw_base::stop ( )
inline

Stops the stopwatch and returns total time (since last reset)

Definition at line 153 of file stopwatch.h.

References adv_stopwatch(), running, and total.

double stopw_base::stop_d ( )
inline

Stops the stopwatch and returns time since last start / read.

Definition at line 162 of file stopwatch.h.

References adv_stopwatch(), and running.

Member Data Documentation

double stopw_base::last_time
protected

The last time we read/started/stopped the clock.

Definition at line 90 of file stopwatch.h.

Referenced by adv_stopwatch(), reset(), and start().

const double stopw_base::overflow_secs
protected

If we overflow once, we miss this many seconds; We assume that internally long ints are used, i.e.

32bit counters on 32bit machines, 64bit on 64bit archs.

Definition at line 99 of file stopwatch.h.

Referenced by adv_stopwatch().

int stopw_base::running
protected

The status.

Definition at line 101 of file stopwatch.h.

Referenced by read(), read_d(), reset(), start(), stop(), and stop_d().

const double stopw_base::secs_per_tick
protected

Used in seconds() to convert internal time to s.

Definition at line 94 of file stopwatch.h.

Referenced by adv_stopwatch(), seconds(), stopwatch_u::seconds(), and stopwatch_us::seconds().

double stopw_base::total
protected

The total elapsed time since construction or reset.

Definition at line 92 of file stopwatch.h.

Referenced by adv_stopwatch(), read(), reset(), and stop().


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