Template Class TimerPool

Class Documentation

template<size_t N = 1>
class TimerPool

TimerPool aggregates N C++11 “timers”; used to profile stages of a computation with high resolution

Note

member functions are not reentrant, use one Timers object per thread

Template Parameters:

N – the number of timers

Public Types

typedef std::chrono::duration<double> dur_t
typedef std::chrono::high_resolution_clock clock_t
typedef std::chrono::time_point<clock_t> time_point_t

Public Functions

inline TimerPool()
inline void set_now_overhead(size_t ns)

use this to report the overhead of now() call; if set, the reported timings will be adjusted for this overhead

Note

this is clearly compiler and system dependent, please measure carefully (turn off turboboost, etc.)

Parameters:

ns – overhead in nanoseconds

inline void start(size_t t = 0)

starts timer t

inline dur_t stop(size_t t = 0)

stops timer t

Returns:

the duration, corrected for overhead, elapsed since the last call to start(t)

inline double read(size_t t = 0) const

reads value (in seconds) of timer t , converted to double

inline void clear()

resets timers to zero

Public Static Functions

static inline time_point_t now()

returns the current time point