File timer.hxx#
Defines
-
AUTO_TIME()#
-
class Timer#
- #include <timer.hxx>
Timing class for performance benchmarking and diagnosis
To record the time spent in a particular function, create a Timer object when you wish to start timing
void someFunction() { Timer timer("test"); // Starts timer } // Timer stops when goes out of scope
Each time this function is called, the total time spent in someFunction will be accumulated. To get the total time spent use getTime()
Timer::getTime("test"); // Returns time in seconds as double
To reset the timer, use resetTime
Timer::resetTime("test"); // Timer reset to zero, returning time as double
Public Types
Public Functions
-
explicit Timer(const std::string &label)#
Create a timer, continuing from last time if the same label has already been used
-
~Timer()#
Stop the timer
-
inline double getTime()#
Get the time in seconds for time particular Timer object
Timer timer("test"); // Some calculation output << timer.getTime(); // timer still counting
-
inline double getTotalTime()#
Get the total time in seconds since the very first initialisation.
-
inline double resetTime()#
Get the time in seconds, reset timer to zero
Public Static Functions
-
static inline double getTotalTime(const std::string &label)#
Total time elapsed since the very first initialisation.
-
static inline double resetTime(const std::string &label)#
The total time in seconds, resets the timer to zero
-
static void cleanup()#
Clears all timers, freeing memory
-
static inline std::map<std::string, timer_info> getAllInfo()#
Return the map of all the individual timers.
-
static void printTimeReport()#
Print a table listing all known timers to
output
Table is sorted by descending largest total time and has columns for total time, percentage of largest total time, total number of hits, and mean time per hit
Private Members
-
timer_info &timing#
The current timing information.
Private Static Functions
-
static timer_info &getInfo(const std::string &label)#
Get a timing info object by name or return a new instance.
-
static double getTime(const timer_info &info)#
Get the elapsed time in seconds for timing info.
-
static double getTotalTime(const timer_info &info)#
Get the total elapsed time in seconds since the first initialisation.
-
static double resetTime(timer_info &info)#
Get the elapsed time, reset timing info to zero.
Private Static Attributes
-
static std::map<std::string, timer_info> info#
Store of existing timing info objects.
-
struct timer_info#
Structure to contain timing information.
Public Members
-
bool running#
Is the timer currently running?
-
clock_type::time_point started#
Start time.
-
bool running#
-
explicit Timer(const std::string &label)#