Quad-SDK
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
quad_utils::FunctionTimer Class Reference

#include <function_timer.h>

Public Member Functions

 FunctionTimer (const char *function_name)
 Constructor for FunctionTimer Class.
 
double reportSilent ()
 Report the statistics without printing to the terminal.
 
double reportStatistics ()
 Report the statistics to the terminal.
 
double reportStatistics (int n)
 Report the averaged statistics to the terminal over a given number of iterations.
 
void reportAndRestart ()
 Report the statistics to the terminal and restart the clock.
 

Private Attributes

std::chrono::time_point< std::chrono::steady_clock > start_time_
 The time at the start of the function call.
 
std::chrono::time_point< std::chrono::steady_clock > stop_time_
 The time at the which the report is queried.
 
char * function_name_
 Name of the function being timed.
 

Detailed Description

A lightweight class for measuring and reporting the duration of functions calls

FunctionTimer keeps track of the amount of time elapsed between start and stop calls, and reporting this along with the name of the function. For some reason the logic in this class takes about 1e-7 s to run so timing functions faster than that will yield inaccurate solutions compared to standard steady clock methods. For functions that take longer than 1e-6 s it should work.

Constructor & Destructor Documentation

◆ FunctionTimer()

quad_utils::FunctionTimer::FunctionTimer ( const char *  function_name)
inline

Constructor for FunctionTimer Class.

Returns
Constructed object of type FunctionTimer

Member Function Documentation

◆ reportSilent()

double quad_utils::FunctionTimer::reportSilent ( )
inline

Report the statistics without printing to the terminal.

Returns
Time in seconds

◆ reportStatistics()

double quad_utils::FunctionTimer::reportStatistics ( int  n)
inline

Report the averaged statistics to the terminal over a given number of iterations.

Parameters
[in]nNumber of iterations executed during elapsed time (used for averaging)

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