QMCPACK
LoopTimer< CLOCK > Class Template Reference
+ Collaboration diagram for LoopTimer< CLOCK >:

Public Member Functions

 LoopTimer ()
 
void start ()
 
void stop ()
 
double get_time_per_iteration () const
 

Private Attributes

int nloop
 
bool ticking
 
CLOCK::time_point start_time
 
double total_time
 

Detailed Description

template<class CLOCK = ChronoClock>
class qmcplusplus::LoopTimer< CLOCK >

Definition at line 51 of file RunTimeManager.h.

Constructor & Destructor Documentation

◆ LoopTimer()

LoopTimer ( )

Definition at line 31 of file RunTimeManager.cpp.

Member Function Documentation

◆ get_time_per_iteration()

double get_time_per_iteration ( ) const

Definition at line 56 of file RunTimeManager.cpp.

Referenced by RunTimeControl< CLOCK >::enough_time_for_next_iteration(), and qmcplusplus::TEST_CASE().

57 {
58  if (nloop > 0)
59  return total_time / nloop;
60  return 0.0;
61 }

◆ start()

void start ( )

Definition at line 35 of file RunTimeManager.cpp.

Referenced by VMC::run(), RMC::run(), DMC::run(), and qmcplusplus::TEST_CASE().

36 {
37  if (ticking)
38  throw std::runtime_error("LoopTimer started already!");
39  start_time = CLOCK::now();
40  ticking = true;
41 }
CLOCK::time_point start_time

◆ stop()

void stop ( )

Definition at line 44 of file RunTimeManager.cpp.

Referenced by VMC::run(), RMC::run(), DMC::run(), and qmcplusplus::TEST_CASE().

45 {
46  if (!ticking)
47  throw std::runtime_error("LoopTimer didn't start but called stop!");
48  nloop++;
49  std::chrono::duration<double> elapsed = CLOCK::now() - start_time;
50  total_time += elapsed.count();
51 
52  ticking = false;
53 }
CLOCK::time_point start_time

Member Data Documentation

◆ nloop

int nloop
private

Definition at line 60 of file RunTimeManager.h.

◆ start_time

CLOCK::time_point start_time
private

Definition at line 62 of file RunTimeManager.h.

◆ ticking

bool ticking
private

Definition at line 61 of file RunTimeManager.h.

◆ total_time

double total_time
private

Definition at line 63 of file RunTimeManager.h.


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