Crypto++ 8.5 Free C++ class library of cryptographic schemes

Public Types | Public Member Functions | List of all members
TimerBase Class Referenceabstract

Base class for timers. More...

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. More...
virtual TimerWord | GetCurrentTimerValue ()=0
| Retrieve the current timer value. More...
virtual TimerWord | TicksPerSecond ()=0
| Retrieve ticks per second. More...
void | StartTimer ()
| Start the timer.
double | ElapsedTimeAsDouble ()
| Retrieve the elapsed time. More...
unsigned long | ElapsedTime ()
| Retrieve the elapsed time. More...

## Detailed Description

Base class for timers.

See also
  ThreadUserTimer, Timer

Definition at line 27 of file hrtimer.h.

## Member Enumeration Documentation

## ◆ Unit

enum TimerBase::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

  unit | the unit of measure
  stuckAtZero | flag

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 Timer, and ThreadUserTimer.

## ◆ 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 Timer, and ThreadUserTimer.

## ◆ 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:

- hrtimer.h