ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
Timer Class Reference

#include <timings.h>

Public Member Functions

 Timer (std::string name_)
 
 ~Timer ()
 
Timeroperator+= (double t)
 
void begin ()
 
void end ()
 
double get_time () const
 

Protected Attributes

double val
 
std::string name
 
boost::chrono::system_clock::time_point t0
 
unsigned long long nCounter
 

Friends

std::ostream & operator<< (std::ostream &os, Timer const &timer)
 

Detailed Description

Definition at line 14 of file timings.h.

Constructor & Destructor Documentation

Timer::Timer ( std::string  name_)
inline

Definition at line 17 of file timings.h.

18  : val(0.0), name(name_), nCounter(0) { }
std::string name
Definition: timings.h:48
unsigned long long nCounter
Definition: timings.h:50
double val
Definition: timings.h:47
Timer::~Timer ( )
inline

Definition at line 20 of file timings.h.

20 { maquis::cout << name << " " << val << ", nCounter : " << nCounter << std::endl; }
std::string name
Definition: timings.h:48
unsigned long long nCounter
Definition: timings.h:50
double val
Definition: timings.h:47

Member Function Documentation

void Timer::begin ( )
inline

Definition at line 27 of file timings.h.

27  {
28  t0 = boost::chrono::system_clock::now();
29  }
boost::chrono::system_clock::time_point t0
Definition: timings.h:49
void Timer::end ( )
inline

Definition at line 31 of file timings.h.

31  {
32  nCounter += 1;
33  boost::chrono::duration<double> sec = boost::chrono::system_clock::now() - t0;
34  val += sec.count();
35  }
boost::chrono::system_clock::time_point t0
Definition: timings.h:49
unsigned long long nCounter
Definition: timings.h:50
double val
Definition: timings.h:47
double Timer::get_time ( ) const
inline

Definition at line 37 of file timings.h.

37  {
38  return val;
39  }
double val
Definition: timings.h:47
Timer& Timer::operator+= ( double  t)
inline

Definition at line 22 of file timings.h.

22  {
23  val += t;
24  return *this;
25  }
double val
Definition: timings.h:47

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
Timer const &  timer 
)
friend

Definition at line 41 of file timings.h.

41  {
42  os << timer.name << " " << timer.val << ", nCounter : " << timer.nCounter;
43  return os;
44  }

Member Data Documentation

std::string Timer::name
protected

Definition at line 48 of file timings.h.

unsigned long long Timer::nCounter
protected

Definition at line 50 of file timings.h.

boost::chrono::system_clock::time_point Timer::t0
protected

Definition at line 49 of file timings.h.

double Timer::val
protected

Definition at line 47 of file timings.h.


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