Crypto++ 8.9
Free C++ class library of cryptographic schemes
Public Types | Public Member Functions | List of all members
TimerBase Class Referenceabstract

Base class for timers. More...

#include <hrtimer.h>

+ Inheritance diagram for TimerBase:

Public Types

enum  Unit { SECONDS = 0 , MILLISECONDS , MICROSECONDS , NANOSECONDS }
 Unit of measure. More...
 

Public Member Functions

 TimerBase (Unit unit, bool stuckAtZero)
 Construct a TimerBase.
 
virtual TimerWord GetCurrentTimerValue ()=0
 Retrieve the current timer value.
 
virtual TimerWord TicksPerSecond ()=0
 Retrieve ticks per second.
 
void StartTimer ()
 Start the timer.
 
double ElapsedTimeAsDouble ()
 Retrieve the elapsed time.
 
unsigned long ElapsedTime ()
 Retrieve the elapsed time.
 

Detailed Description

Base class for timers.

See also
ThreadUserTimer, Timer

Definition at line 27 of file hrtimer.h.

Member Enumeration Documentation

◆ Unit

Unit of measure.

Unit selects the unit of measure as returned by functions ElapsedTimeAsDouble() and ElapsedTime().

See also
ElapsedTimeAsDouble, ElapsedTime
Enumerator
SECONDS 

Timer unit is seconds.

All timers support seconds

MILLISECONDS 

Timer unit is milliseconds.

All timers support milliseconds

MICROSECONDS 

Timer unit is microseconds.

The timer requires hardware support microseconds

NANOSECONDS 

Timer unit is nanoseconds.

The timer requires hardware support nanoseconds

Definition at line 34 of file hrtimer.h.

Constructor & Destructor Documentation

◆ TimerBase()

TimerBase::TimerBase ( Unit unit,
bool stuckAtZero )
inline

Construct a TimerBase.

Parameters
unitthe unit of measure
stuckAtZeroflag

Definition at line 52 of file hrtimer.h.

Member Function Documentation

◆ GetCurrentTimerValue()

virtual TimerWord TimerBase::GetCurrentTimerValue ( )
pure virtual

Retrieve the current timer value.

Returns
the current timer value

Implemented in ThreadUserTimer, and Timer.

◆ TicksPerSecond()

virtual TimerWord TimerBase::TicksPerSecond ( )
pure virtual

Retrieve ticks per second.

Returns
ticks per second

TicksPerSecond() is not the timer resolution. It is a conversion factor into seconds.

Implemented in ThreadUserTimer, and Timer.

◆ ElapsedTimeAsDouble()

double TimerBase::ElapsedTimeAsDouble ( )

Retrieve the elapsed time.

Returns
the elapsed time as a double

The return value of ElapsedTimeAsDouble() depends upon the Unit selected during construction of the timer. For example, if Unit = SECONDS and ElapsedTimeAsDouble() returns 3, then the timer has run for 3 seconds. If Unit = MILLISECONDS and ElapsedTimeAsDouble() returns 3000, then the timer has run for 3 seconds.

See also
Unit, ElapsedTime

◆ ElapsedTime()

unsigned long TimerBase::ElapsedTime ( )

Retrieve the elapsed time.

Returns
the elapsed time as an unsigned long

The return value of ElapsedTime() depends upon the Unit selected during construction of the timer. For example, if Unit = SECONDS and ElapsedTime() returns 3, then the timer has run for 3 seconds. If Unit = MILLISECONDS and ElapsedTime() returns 3000, then the timer has run for 3 seconds.

See also
Unit, ElapsedTimeAsDouble

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