HDK
|
#include <timer.h>
Public Types | |
enum | StartNowVal { DontStartNow, StartNow } |
enum | PrintDtrVal { DontPrintDtr, PrintDtr } |
typedef long long | ticks_t |
Public Member Functions | |
Timer (StartNowVal startnow=StartNow, PrintDtrVal printdtr=DontPrintDtr, const char *name=NULL) | |
Timer (bool startnow) | |
~Timer () | |
Destructor. More... | |
void | start () |
Start (or restart) ticking, if we are not currently. More... | |
double | stop () |
void | reset (void) |
ticks_t | lap_ticks () |
double | lap () |
ticks_t | ticks () const |
double | operator() (void) const |
ticks_t | ticks_since_start (void) const |
double | time_since_start (void) const |
bool | ticking () const |
Is the timer currently ticking? More... | |
void | add_ticks (ticks_t delta) |
void | add_seconds (double t) |
Static Public Member Functions | |
static double | seconds (ticks_t ticks) |
Convert number of ticks to seconds. More... | |
Friends | |
class | TimerSetupOnce |
Simple timer class.
This class allows you to time things, for runtime statistics and the like. The simplest usage pattern is illustrated by the following example:
These are not very high-resolution timers. A Timer begin/end pair takes somewhere in the neighborhood of 0.1 - 0.3 us (microseconds), and can vary by OS. This means that (a) it's not useful for timing individual events near or below that resolution (things that would take only tens or hundreds of processor cycles, for example), and (b) calling it millions of times could make your program appreciably more expensive due to the timers themselves.
typedef long long Timer::ticks_t |
enum Timer::PrintDtrVal |
enum Timer::StartNowVal |
|
inline |
|
inline |
|
inline |
Force an offset to the total, in seconds. This value may be negative to subtract from the total. To avoid disrupting the timer in progress, this is added to the total elapsed time but not to the current lap, so it will be reflected in ticks() or seconds(), but will NOT be reflected in ticks_since_start() or time_since_start().
Force an offset to the total, in ticks. This value may be negative to subtract from the total. To avoid disrupting the timer in progress, this is added to the total elapsed time but not to the current lap, so it will be reflected in ticks() or seconds(), but will NOT be reflected in ticks_since_start() or time_since_start().
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |