Frobby  0.9.5
Public Member Functions | Private Attributes | List of all members
Timer Class Reference

Measures spans of CPU time. More...

#include <Timer.h>

Public Member Functions

 Timer ()
 
void reset ()
 Resets the amount of elapsed CPU time to zero. More...
 
unsigned long getMilliseconds () const
 Returns the number of CPU milliseconds since the last reset. More...
 
void print (FILE *out) const
 Prints the elapsed time in a human readable format. More...
 

Private Attributes

std::clock_t _clocksAtReset
 

Detailed Description

Measures spans of CPU time.

The internal record of time can overflow quickly. If clock_t is 32 bits unsigned and CLOCKS_PER_TIC is one million then overflow will occur after 71 minutes.

Definition at line 27 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( )
inline

Definition at line 29 of file Timer.h.

Member Function Documentation

◆ getMilliseconds()

unsigned long Timer::getMilliseconds ( ) const

Returns the number of CPU milliseconds since the last reset.

See class description for time span overflow limitations.

Definition at line 20 of file Timer.cpp.

◆ print()

void Timer::print ( FILE *  out) const

Prints the elapsed time in a human readable format.

See class description for time span overflow limitations.

Definition at line 29 of file Timer.cpp.

◆ reset()

void Timer::reset ( )
inline

Resets the amount of elapsed CPU time to zero.

Definition at line 32 of file Timer.h.

Member Data Documentation

◆ _clocksAtReset

std::clock_t Timer::_clocksAtReset
private

Definition at line 43 of file Timer.h.


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