Belle II Software light-2505-deimos
Timer Class Reference

Small helper class that prints its lifetime when destroyed. More...

#include <Utils.h>

Collaboration diagram for Timer:

Public Member Functions

 Timer (std::string text="")
 Constructor, with some identifying text.
 

Private Attributes

double m_startTime
 time at start (in ns).
 
std::string m_text
 identifying text (printed at end).
 

Detailed Description

Small helper class that prints its lifetime when destroyed.

Definition at line 79 of file Utils.h.

Constructor & Destructor Documentation

◆ Timer()

Timer ( std::string text = "")
explicit

Constructor, with some identifying text.

Definition at line 89 of file Utils.cc.

89 :
90 m_startTime(getClock()),
91 m_text(std::move(text))
92 { }
double getClock()
Return current value of the real-time clock.
Definition Utils.cc:66

◆ ~Timer()

~Timer ( )

Definition at line 94 of file Utils.cc.

95 {
96 double elapsed = (getClock() - m_startTime) / Unit::ms;
97 B2INFO(m_text << " " << std::fixed << std::setprecision(3) << elapsed << " ms");
98 }
static const double ms
[millisecond]
Definition Unit.h:96

Member Data Documentation

◆ m_startTime

double m_startTime
private

time at start (in ns).

Definition at line 85 of file Utils.h.

◆ m_text

std::string m_text
private

identifying text (printed at end).

Definition at line 86 of file Utils.h.


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