NAP
Public Member Functions | List of all members
Timer< Clock > Class Template Reference

#include <nap/timer.h>

Public Member Functions

 Timer ()=default
 
virtual ~Timer ()=default
 
void start ()
 
std::chrono::time_point< Clock > getStartTime () const
 
void stop ()
 
void reset ()
 
double getElapsedTime () const
 
float getElapsedTimeFloat () const
 
uint32_t getTicks () const
 
NanoSeconds getNanos () const
 
MicroSeconds getMicros () const
 
Milliseconds getMillis () const
 
Seconds getSeconds () const
 
Minutes getMinutes () const
 
Hours getHours () const
 
template<typename T >
get () const
 

Description

template<typename Clock>
class nap::Timer< Clock >

Keeps track of time from the moment the timer is started. This is a template Timer that can work with various chrono clocks. Use the utility classes nap::SystemTimer and nap::HighResolutionTimer to work with specific clocks. The template type T should be a specific type of chrono clock, ie: HighResolutionClock etc. This timer is not threaded and doesn't work with callbacks.

Constructor & Destructor Documentation

◆ Timer()

Timer ( )
default

◆ ~Timer()

virtual ~Timer ( )
virtualdefault

Member Function Documentation

◆ get()

T get

Utility function that casts this timer's duration to a duration of type T. Where T can be NanoSeconds, MicroSeconds, MilliSeconds etc.

Returns
elapsed time as duration of type T (Microseconds, Milliseconds, Seconds, etc.)

◆ getElapsedTime()

double getElapsedTime
Returns
the elapsed time in seconds as double

◆ getElapsedTimeFloat()

float getElapsedTimeFloat
Returns
the elapsed time in seconds as a float

◆ getHours()

Hours getHours ( ) const
Returns
elapsed time in hours

◆ getMicros()

MicroSeconds getMicros ( ) const
Returns
elapsed time in microseconds

◆ getMillis()

Milliseconds getMillis ( ) const
Returns
elapsed time in milliseconds

◆ getMinutes()

Minutes getMinutes ( ) const
Returns
elapsed time in minutes

◆ getNanos()

NanoSeconds getNanos ( ) const
Returns
elapsed time in nanoseconds

◆ getSeconds()

Seconds getSeconds ( ) const
Returns
elapsed time in seconds

◆ getStartTime()

std::chrono::time_point< Clock > getStartTime

Returns the start time.

Returns
timer start time

◆ getTicks()

uint32_t getTicks
Returns
amount of processed ticks in milliseconds

◆ reset()

void reset

Resets the timer, essentially starting it again.

◆ start()

void start

Start the timer

◆ stop()

void stop

Stops the timer, start time is set to 0.

This call is deprecated because setting the start time to 0 results in large time time deltas, depending on the clock that is used. This call therefore serves no purpose whatsoever and will be removed.