QMCPACK
TimerType< CLOCK > Class Template Reference

Timer accumulates time and call counts. More...

+ Collaboration diagram for TimerType< CLOCK >:

Public Member Functions

void start ()
 
void stop ()
 
std::map< StackKey, double > & get_per_stack_total_time ()
 
StackKeyget_stack_key ()
 
double get_total () const
 
long get_num_calls () const
 
double get_total (const StackKey &key)
 
long get_num_calls (const StackKey &key)
 
timer_id_t get_id () const
 
void set_id (timer_id_t id)
 
std::string get_name () const
 
void reset ()
 
 TimerType (const std::string &myname, TimerManager< TimerType< CLOCK >> *mymanager, timer_levels mytimer=timer_level_fine)
 
 TimerType (const TimerType &o)=delete
 
void set_name (const std::string &myname)
 
void set_active (const bool &is_active)
 
void set_active_by_timer_threshold (const timer_levels threshold)
 

Protected Attributes

CLOCK::time_point start_time
 start time of the current measurement More...
 
double total_time
 total time accumulated of all the calls More...
 
long num_calls
 total call counts More...
 
std::string name
 name of this timer More...
 
bool active
 if false, timer start/stop becomes no-op. More...
 
timer_levels timer_level
 timer level More...
 
timer_id_t timer_id
 timer id in registered in the manager More...
 
TimerManager< TimerType< CLOCK > > * manager
 timer manager which allocated this timer object. nullptr if USE_STACK_TIMERS is not used. More...
 
StackKey current_stack_key
 stack key of the current measurement More...
 
std::map< StackKey, double > per_stack_total_time
 total time accumulated per stack key More...
 
std::map< StackKey, long > per_stack_num_calls
 total call counts per stack key More...
 

Friends

template<class CLOCK1 >
void set_total_time (TimerType< CLOCK1 > *timer, double total_time_input)
 
template<class CLOCK1 >
void set_num_calls (TimerType< CLOCK1 > *timer, long num_calls_input)
 

Detailed Description

template<class CLOCK>
class qmcplusplus::TimerType< CLOCK >

Timer accumulates time and call counts.

Template Parameters
CLOCKcan be a std::chrono clock or FakeChronoClock

Definition at line 135 of file NewTimer.h.

Constructor & Destructor Documentation

◆ TimerType() [1/2]

TimerType ( const std::string &  myname,
TimerManager< TimerType< CLOCK >> *  mymanager,
timer_levels  mytimer = timer_level_fine 
)
inline

Definition at line 198 of file NewTimer.h.

201  : total_time(0.0),
202  num_calls(0),
203  name(myname),
204  active(true),
205  timer_level(mytimer),
206  timer_id(0),
207 #ifdef USE_STACK_TIMERS
208  manager(mymanager)
209 #else
210  manager(nullptr)
211 #endif
212  {
213 #ifdef USE_VTUNE_TASKS
214  task_name = __itt_string_handle_create(myname.c_str());
215 #endif
216  }
timer_id_t timer_id
timer id in registered in the manager
Definition: NewTimer.h:151
long num_calls
total call counts
Definition: NewTimer.h:143
TimerManager< TimerType< CLOCK > > * manager
timer manager which allocated this timer object. nullptr if USE_STACK_TIMERS is not used...
Definition: NewTimer.h:153
bool active
if false, timer start/stop becomes no-op.
Definition: NewTimer.h:147
double total_time
total time accumulated of all the calls
Definition: NewTimer.h:141
std::string name
name of this timer
Definition: NewTimer.h:145
timer_levels timer_level
timer level
Definition: NewTimer.h:149

◆ TimerType() [2/2]

TimerType ( const TimerType< CLOCK > &  o)
delete

Member Function Documentation

◆ get_id()

timer_id_t get_id ( ) const
inline

Definition at line 186 of file NewTimer.h.

References TimerType< CLOCK >::timer_id.

186 { return timer_id; }
timer_id_t timer_id
timer id in registered in the manager
Definition: NewTimer.h:151

◆ get_name()

std::string get_name ( ) const
inline

Definition at line 190 of file NewTimer.h.

References TimerType< CLOCK >::name.

190 { return name; }
std::string name
name of this timer
Definition: NewTimer.h:145

◆ get_num_calls() [1/2]

long get_num_calls ( ) const
inline

Definition at line 179 of file NewTimer.h.

References TimerType< CLOCK >::num_calls.

Referenced by qmcplusplus::TEST_CASE().

179 { return num_calls; }
long num_calls
total call counts
Definition: NewTimer.h:143

◆ get_num_calls() [2/2]

long get_num_calls ( const StackKey key)
inline

Definition at line 183 of file NewTimer.h.

References TimerType< CLOCK >::per_stack_num_calls.

183 { return per_stack_num_calls[key]; }
std::map< StackKey, long > per_stack_num_calls
total call counts per stack key
Definition: NewTimer.h:161

◆ get_per_stack_total_time()

std::map<StackKey, double>& get_per_stack_total_time ( )
inline

Definition at line 172 of file NewTimer.h.

References TimerType< CLOCK >::per_stack_total_time.

172 { return per_stack_total_time; }
std::map< StackKey, double > per_stack_total_time
total time accumulated per stack key
Definition: NewTimer.h:159

◆ get_stack_key()

StackKey& get_stack_key ( )
inline

Definition at line 174 of file NewTimer.h.

References TimerType< CLOCK >::current_stack_key.

174 { return current_stack_key; }
StackKey current_stack_key
stack key of the current measurement
Definition: NewTimer.h:156

◆ get_total() [1/2]

double get_total ( ) const
inline

Definition at line 178 of file NewTimer.h.

References TimerType< CLOCK >::total_time.

Referenced by qmcplusplus::TEST_CASE().

178 { return total_time; }
double total_time
total time accumulated of all the calls
Definition: NewTimer.h:141

◆ get_total() [2/2]

double get_total ( const StackKey key)
inline

Definition at line 182 of file NewTimer.h.

References TimerType< CLOCK >::per_stack_total_time.

182 { return per_stack_total_time[key]; }
std::map< StackKey, double > per_stack_total_time
total time accumulated per stack key
Definition: NewTimer.h:159

◆ reset()

void reset ( )
inline

Definition at line 192 of file NewTimer.h.

References TimerType< CLOCK >::num_calls, and TimerType< CLOCK >::total_time.

193  {
194  num_calls = 0;
195  total_time = 0.0;
196  }
long num_calls
total call counts
Definition: NewTimer.h:143
double total_time
total time accumulated of all the calls
Definition: NewTimer.h:141

◆ set_active()

void set_active ( const bool &  is_active)
inline

Definition at line 222 of file NewTimer.h.

References TimerType< CLOCK >::active.

222 { active = is_active; }
bool active
if false, timer start/stop becomes no-op.
Definition: NewTimer.h:147

◆ set_active_by_timer_threshold()

void set_active_by_timer_threshold ( const timer_levels  threshold)

Definition at line 124 of file NewTimer.cpp.

125 {
126  if (timer_level <= threshold)
127  active = true;
128  else
129  active = false;
130 }
bool active
if false, timer start/stop becomes no-op.
Definition: NewTimer.h:147
timer_levels timer_level
timer level
Definition: NewTimer.h:149

◆ set_id()

void set_id ( timer_id_t  id)
inline

Definition at line 188 of file NewTimer.h.

References TimerType< CLOCK >::timer_id.

188 { timer_id = id; }
timer_id_t timer_id
timer id in registered in the manager
Definition: NewTimer.h:151

◆ set_name()

void set_name ( const std::string &  myname)
inline

Definition at line 220 of file NewTimer.h.

References TimerType< CLOCK >::name.

220 { name = myname; }
std::string name
name of this timer
Definition: NewTimer.h:145

◆ start()

◆ stop()

Friends And Related Function Documentation

◆ set_num_calls

void set_num_calls ( TimerType< CLOCK1 > *  timer,
long  num_calls_input 
)
friend

◆ set_total_time

void set_total_time ( TimerType< CLOCK1 > *  timer,
double  total_time_input 
)
friend

Member Data Documentation

◆ active

bool active
protected

if false, timer start/stop becomes no-op.

Definition at line 147 of file NewTimer.h.

Referenced by TimerType< CLOCK >::set_active().

◆ current_stack_key

StackKey current_stack_key
protected

stack key of the current measurement

Definition at line 156 of file NewTimer.h.

Referenced by TimerType< CLOCK >::get_stack_key().

◆ manager

TimerManager<TimerType<CLOCK> >* manager
protected

timer manager which allocated this timer object. nullptr if USE_STACK_TIMERS is not used.

Definition at line 153 of file NewTimer.h.

◆ name

std::string name
protected

name of this timer

Definition at line 145 of file NewTimer.h.

Referenced by TimerType< CLOCK >::get_name(), and TimerType< CLOCK >::set_name().

◆ num_calls

long num_calls
protected

total call counts

Definition at line 143 of file NewTimer.h.

Referenced by TimerType< CLOCK >::get_num_calls(), TimerType< CLOCK >::reset(), and qmcplusplus::set_num_calls().

◆ per_stack_num_calls

std::map<StackKey, long> per_stack_num_calls
protected

total call counts per stack key

Definition at line 161 of file NewTimer.h.

Referenced by TimerType< CLOCK >::get_num_calls().

◆ per_stack_total_time

std::map<StackKey, double> per_stack_total_time
protected

total time accumulated per stack key

Definition at line 159 of file NewTimer.h.

Referenced by TimerType< CLOCK >::get_per_stack_total_time(), and TimerType< CLOCK >::get_total().

◆ start_time

CLOCK::time_point start_time
protected

start time of the current measurement

Definition at line 139 of file NewTimer.h.

◆ timer_id

timer_id_t timer_id
protected

timer id in registered in the manager

Definition at line 151 of file NewTimer.h.

Referenced by TimerType< CLOCK >::get_id(), and TimerType< CLOCK >::set_id().

◆ timer_level

timer_levels timer_level
protected

timer level

Definition at line 149 of file NewTimer.h.

◆ total_time

double total_time
protected

total time accumulated of all the calls

Definition at line 141 of file NewTimer.h.

Referenced by TimerType< CLOCK >::get_total(), TimerType< CLOCK >::reset(), and qmcplusplus::set_total_time().


The documentation for this class was generated from the following files: