Utility functions for measuering time. More...
#include <ctime>
#include <iostream>
#include "timing.h"
#include <tr1/unordered_map>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstring>
Classes | |
class | FHEtimer |
A simple class to toggle timing information on and off. More... | |
Typedefs | |
typedef tr1::unordered_map < const char *, FHEtimer > | timerMap |
Functions | |
bool | string_compare (const char *a, const char *b) |
void | resetFHEtimer (const char *fncName) |
Reset a timer for some label to zero. | |
void | startFHEtimer (const char *fncName) |
Start a timer. | |
void | stopFHEtimer (const char *fncName) |
Stop a timer. | |
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) |
Print the value of all timers to stream. | |
Variables | |
bool | FHEtimersOn =false |
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).