code_profiler
Public Member Functions | Private Attributes | List of all members
tue::LoopTimer Class Reference

#include <loop_timer.h>

Public Member Functions

long unsigned int getIterationCount () const
 Get total number of loop iterations. When running, the current iteration is included. More...
 
long double getTotalTime () const
 Get the total elapsed time since the first start.Stops the current iteration when running. More...
 
 LoopTimer ()
 
void reset ()
 Stop the timer and reset all counters to zero. More...
 
void start ()
 
void stop ()
 
 ~LoopTimer ()=default
 
long double getTotalLoopTime ()
 Get total elapsed time during the loops. Stops the current iteration when running. More...
 
long double getTotalLoopTime () const
 const version which excludes the current loop iteration when running More...
 
long double getAverageLoopTime ()
 Get average time per loop iteration. Stops the current iteration when running. More...
 
long double getAverageLoopTime () const
 const version which excludes the current loop iteration when running More...
 
double getLoopUsagePercentage ()
 Get average percentage of total time used by the loop. More...
 
double getLoopUsagePercentage () const
 const version which excludes the current loop iteration when running More...
 

Private Attributes

long double c_
 Compensation for lost low-order bits. More...
 
long unsigned int counts_
 loop counter More...
 
long double sum_
 Sum so far. More...
 
tue::Timer timer_
 
tue::Timer total_timer_
 

Detailed Description

Definition at line 11 of file loop_timer.h.

Constructor & Destructor Documentation

◆ LoopTimer()

tue::LoopTimer::LoopTimer ( )

Definition at line 9 of file loop_timer.cpp.

◆ ~LoopTimer()

tue::LoopTimer::~LoopTimer ( )
default

Member Function Documentation

◆ getAverageLoopTime() [1/2]

long double tue::LoopTimer::getAverageLoopTime ( )

Get average time per loop iteration. Stops the current iteration when running.

Returns
Average time per loop iteration in seconds

Definition at line 56 of file loop_timer.cpp.

◆ getAverageLoopTime() [2/2]

long double tue::LoopTimer::getAverageLoopTime ( ) const

const version which excludes the current loop iteration when running

◆ getIterationCount()

long unsigned int tue::LoopTimer::getIterationCount ( ) const
inline

Get total number of loop iterations. When running, the current iteration is included.

Returns
Number of loop iterations

Definition at line 48 of file loop_timer.h.

◆ getLoopUsagePercentage() [1/2]

double tue::LoopTimer::getLoopUsagePercentage ( )

Get average percentage of total time used by the loop.

Returns
Percentage in range [0-1]

Definition at line 78 of file loop_timer.cpp.

◆ getLoopUsagePercentage() [2/2]

double tue::LoopTimer::getLoopUsagePercentage ( ) const

const version which excludes the current loop iteration when running

◆ getTotalLoopTime() [1/2]

long double tue::LoopTimer::getTotalLoopTime ( )

Get total elapsed time during the loops. Stops the current iteration when running.

Returns
Elapsed time in seconds

Definition at line 40 of file loop_timer.cpp.

◆ getTotalLoopTime() [2/2]

long double tue::LoopTimer::getTotalLoopTime ( ) const

const version which excludes the current loop iteration when running

◆ getTotalTime()

long double tue::LoopTimer::getTotalTime ( ) const

Get the total elapsed time since the first start.Stops the current iteration when running.

Returns
Total time since start in seconds

Definition at line 73 of file loop_timer.cpp.

◆ reset()

void tue::LoopTimer::reset ( )

Stop the timer and reset all counters to zero.

Definition at line 31 of file loop_timer.cpp.

◆ start()

void tue::LoopTimer::start ( )

Definition at line 13 of file loop_timer.cpp.

◆ stop()

void tue::LoopTimer::stop ( )

Definition at line 21 of file loop_timer.cpp.

Member Data Documentation

◆ c_

long double tue::LoopTimer::c_
private

Compensation for lost low-order bits.

Definition at line 30 of file loop_timer.h.

◆ counts_

long unsigned int tue::LoopTimer::counts_
private

loop counter

Definition at line 20 of file loop_timer.h.

◆ sum_

long double tue::LoopTimer::sum_
private

Sum so far.

Definition at line 25 of file loop_timer.h.

◆ timer_

tue::Timer tue::LoopTimer::timer_
private

Definition at line 14 of file loop_timer.h.

◆ total_timer_

tue::Timer tue::LoopTimer::total_timer_
private

Definition at line 15 of file loop_timer.h.


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