ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
psc::Utils::ScopeTimer Class Reference

Very simple timer class. More...

#include <Utils.h>

Collaboration diagram for psc::Utils::ScopeTimer:

Public Member Functions

 ScopeTimer (const std::string &descr="Timer")
 Create timer and start timing. More...
 
 ~ScopeTimer ()
 Stop timer (if still running) More...
 
void stop ()
 Stop timer manually. More...
 

Private Attributes

std::string m_descr
 description of timer More...
 
std::chrono::system_clock::time_point m_t1
 start time More...
 
bool m_running
 timer running? More...
 

Detailed Description

Very simple timer class.

Time between constructor and destructor call is measured and printed

Definition at line 56 of file HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h.

Constructor & Destructor Documentation

◆ ScopeTimer()

psc::Utils::ScopeTimer::ScopeTimer ( const std::string &  descr = "Timer")

Create timer and start timing.

Definition at line 66 of file HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx.

66  :
67  m_descr(descr),
69  m_running(true)
70 {
71  std::tm lt;
72  auto t = std::chrono::system_clock::to_time_t(m_t1);
73  localtime_r(&t, &lt);
74  ERS_LOG( m_descr << " started at time: " << std::put_time(&lt, "%Y-%m-%d %H:%M:%S") );
75 }

◆ ~ScopeTimer()

psc::Utils::ScopeTimer::~ScopeTimer ( )
inline

Stop timer (if still running)

Definition at line 66 of file HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h.

66 { if (m_running) stop(); }

Member Function Documentation

◆ stop()

void psc::Utils::ScopeTimer::stop ( )

Stop timer manually.

Definition at line 77 of file HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx.

78 {
80  auto dt_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - m_t1);
81  ERS_LOG( m_descr << " finished. Time used [ms] = " << dt_ms.count() );
82  m_running = false;
83 }

Member Data Documentation

◆ m_descr

std::string psc::Utils::ScopeTimer::m_descr
private

description of timer

Definition at line 74 of file HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h.

◆ m_running

bool psc::Utils::ScopeTimer::m_running
private

timer running?

Definition at line 76 of file HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h.

◆ m_t1

std::chrono::system_clock::time_point psc::Utils::ScopeTimer::m_t1
private

start time

Definition at line 75 of file HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h.


The documentation for this class was generated from the following files:
psc::Utils::ScopeTimer::m_running
bool m_running
timer running?
Definition: HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h:76
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
psc::Utils::ScopeTimer::m_descr
std::string m_descr
description of timer
Definition: HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h:74
python.handimod.now
now
Definition: handimod.py:675
python.TransformConfig.descr
descr
print "%s.properties()" % self.__name__
Definition: TransformConfig.py:360
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
psc::Utils::ScopeTimer::stop
void stop()
Stop timer manually.
Definition: HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx:77
psc::Utils::ScopeTimer::m_t1
std::chrono::system_clock::time_point m_t1
start time
Definition: HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h:75