Utility functions for measuering time. More...
#include <iostream>
Go to the source code of this file.
Macros | |
#define | FHE_TIMER_START {if (areTimersOn()) startFHEtimer(__func__);} |
#define | FHE_TIMER_STOP {if (areTimersOn()) stopFHEtimer(__func__);} |
#define | FHE_NTIMER_START(n) {if (areTimersOn()) startFHEtimer(n);} |
#define | FHE_NTIMER_STOP(n) {if (areTimersOn()) stopFHEtimer(n);} |
Functions | |
void | setTimersOn () |
void | setTimersOff () |
bool | areTimersOn () |
void | startFHEtimer (const char *fncName) |
Start a timer. | |
void | stopFHEtimer (const char *fncName) |
Stop a timer. | |
void | resetFHEtimer (const char *fncName) |
Reset a timer for some label to zero. | |
double | getTime4func (const char *fncName) |
Read the value of a timer (in seconds) | |
long | getNumCalls4func (const char *fncName) |
Returns number of calls for that timer. | |
void | resetAllTimers () |
void | printAllTimers (std::ostream &str=std::cerr) |
Print the value of all timers to stream. | |
Variables | |
bool | FHEtimersOn |
Utility functions for measuering time.
This module contains some utility functions for measuring the time that various methods take to execute. To use it, we insert the macro FHE_TIMER_START at the beginning of the method(s) that we want to time and FHE_TIMER_STOP at the end, then the main program needs to call the function setTimersOn() to activate the timers and setTimersOff() to pause them. To obtain the value of a given timer (in seconds), the application can use the function getTime4func(const char *fncName), and the function printAllTimers() prints the values of all timers to an output stream.
Using this method we can have at most one timer per method/function, and the timer is called by the same name as the function itself (using the built-in macro __func__). We can also use the "lower level" methods startFHEtimer(name), stopFHEtimer(name), and resetFHEtimer(name) to add timers with arbitrary names (not necessarily associated with functions).