1#ifndef FUNCTION_TIMER_H
2#define FUNCTION_TIMER_H
35 std::chrono::duration<double> elapsed =
36 std::chrono::duration_cast<std::chrono::duration<double>>(
stop_time_ -
38 double current_time = elapsed.count();
47 printf(
"Time spent in %s = %.2es\n",
function_name_, current_time);
59 printf(
"Average time spent in %s = %.2es\n",
function_name_, avg_time);
73 std::chrono::time_point<std::chrono::steady_clock>
start_time_;
76 std::chrono::time_point<std::chrono::steady_clock>
stop_time_;
Definition function_timer.h:18
double reportStatistics()
Report the statistics to the terminal.
Definition function_timer.h:45
std::chrono::time_point< std::chrono::steady_clock > stop_time_
The time at the which the report is queried.
Definition function_timer.h:76
FunctionTimer(const char *function_name)
Constructor for FunctionTimer Class.
Definition function_timer.h:24
void reportAndRestart()
Report the statistics to the terminal and restart the clock.
Definition function_timer.h:66
char * function_name_
Name of the function being timed.
Definition function_timer.h:79
double reportSilent()
Report the statistics without printing to the terminal.
Definition function_timer.h:33
double reportStatistics(int n)
Report the averaged statistics to the terminal over a given number of iterations.
Definition function_timer.h:57
std::chrono::time_point< std::chrono::steady_clock > start_time_
The time at the start of the function call.
Definition function_timer.h:73