ATLAS Offline Software
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Monitored::Timer< unit > Class Template Referenceabstract

A monitored timer. More...

#include <MonitoredTimer.h>

Inheritance diagram for Monitored::Timer< unit >:
Collaboration diagram for Monitored::Timer< unit >:

Public Member Functions

 Timer (std::string name)
 
 Timer (Timer &&)=default
 
 Timer (Timer const &)=delete
 
void start ()
 
void stop ()
 
 operator double () const
 duration (in unit) between start and stop (or current time) More...
 
virtual double get (size_t) const override
 
virtual std::string getString ([[maybe_unused]] size_t i) const override
 
virtual bool hasStringRepresentation () const override
 indcates that the stored content can be converted to strings More...
 
virtual size_t size () const override
 gives size of vector representation More...
 
const std::string & name () const
 
virtual std::string getString (size_t) const =0
 

Public Attributes

friend MonitoredGroup
 

Private Types

typedef std::chrono::high_resolution_clock clock_type
 

Private Member Functions

Timeroperator= (Timer const &)=delete
 

Private Attributes

clock_type::time_point m_startTime
 
clock_type::time_point m_stopTime
 
const std::string m_name
 

Detailed Description

template<typename unit = std::chrono::microseconds>
class Monitored::Timer< unit >

A monitored timer.

The time is measured either between explicit stop/start calls or between the creation and the time the value is read by the monitoring tool.

A strict naming convention is enforced. Timers need to start with the string "TIME_".

Template Parameters
unitUnit of elapsed time (std::chrono::duration)

Examples

// The name of the monitored timer has to start with "TIME", else runtime error.
auto t1 = Monitored::Timer( "TIME_t1" ); // default is microseconds
{
auto group = Monitored::Group( monTool, t1, t2 );
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
See also
Monitored::ScopedTimer

Definition at line 32 of file MonitoredTimer.h.

Member Typedef Documentation

◆ clock_type

template<typename unit = std::chrono::microseconds>
typedef std::chrono::high_resolution_clock Monitored::Timer< unit >::clock_type
private

Definition at line 50 of file MonitoredTimer.h.

Constructor & Destructor Documentation

◆ Timer() [1/3]

template<typename unit >
Timer::Timer ( std::string  name)

Definition at line 59 of file MonitoredTimer.h.

59  : IMonitoredVariable(std::move(tname)) {
61  start();
62  }

◆ Timer() [2/3]

template<typename unit = std::chrono::microseconds>
Monitored::Timer< unit >::Timer ( Timer< unit > &&  )
default

◆ Timer() [3/3]

template<typename unit = std::chrono::microseconds>
Monitored::Timer< unit >::Timer ( Timer< unit > const )
delete

Member Function Documentation

◆ get()

template<typename unit = std::chrono::microseconds>
virtual double Monitored::Timer< unit >::get ( size_t  ) const
inlineoverridevirtual

Implements Monitored::IMonitoredVariable.

Definition at line 43 of file MonitoredTimer.h.

43 { return double(*this); }

◆ getString() [1/2]

template<typename unit = std::chrono::microseconds>
virtual std::string Monitored::Timer< unit >::getString ( [[maybe_unused] ] size_t  i) const
inlineoverridevirtual

Definition at line 44 of file MonitoredTimer.h.

44 { return {}; }

◆ getString() [2/2]

virtual std::string Monitored::IMonitoredVariable::getString ( size_t  ) const
pure virtualinherited

Implemented in Monitored::Scalar< T >.

◆ hasStringRepresentation()

template<typename unit = std::chrono::microseconds>
virtual bool Monitored::Timer< unit >::hasStringRepresentation ( ) const
inlineoverridevirtual

indcates that the stored content can be converted to strings

Implements Monitored::IMonitoredVariable.

Definition at line 45 of file MonitoredTimer.h.

45 { return false; };

◆ name()

const std::string& Monitored::IMonitoredVariable::name ( ) const
inlineinherited

Definition at line 19 of file IMonitoredVariable.h.

19 { return m_name; }

◆ operator double()

template<typename unit >
Timer::operator double

duration (in unit) between start and stop (or current time)

Definition at line 70 of file MonitoredTimer.h.

70  {
71  clock_type::time_point stopTime = m_stopTime;
72  if (stopTime == clock_type::time_point()) // never stopped
73  stopTime = clock_type::now();
74  auto d = std::chrono::duration_cast<unit>(stopTime - m_startTime);
75  return d.count();
76  }

◆ operator=()

template<typename unit = std::chrono::microseconds>
Timer& Monitored::Timer< unit >::operator= ( Timer< unit > const )
privatedelete

◆ size()

template<typename unit = std::chrono::microseconds>
virtual size_t Monitored::Timer< unit >::size ( ) const
inlineoverridevirtual

gives size of vector representation

Implements Monitored::IMonitoredVariable.

Definition at line 46 of file MonitoredTimer.h.

46 { return 1; }

◆ start()

template<typename unit >
void Timer::start

Definition at line 64 of file MonitoredTimer.h.

◆ stop()

template<typename unit >
void Timer::stop

Definition at line 67 of file MonitoredTimer.h.

Member Data Documentation

◆ m_name

const std::string Monitored::IMonitoredVariable::m_name
privateinherited

Definition at line 31 of file IMonitoredVariable.h.

◆ m_startTime

template<typename unit = std::chrono::microseconds>
clock_type::time_point Monitored::Timer< unit >::m_startTime
private

Definition at line 51 of file MonitoredTimer.h.

◆ m_stopTime

template<typename unit = std::chrono::microseconds>
clock_type::time_point Monitored::Timer< unit >::m_stopTime
private

Definition at line 52 of file MonitoredTimer.h.

◆ MonitoredGroup

friend Monitored::IMonitoredVariable::MonitoredGroup
inherited

Definition at line 16 of file IMonitoredVariable.h.


The documentation for this class was generated from the following file:
Monitored::checkNamingConvention
void checkNamingConvention(std::string_view name)
Definition: MonitoredTimer.cxx:10
Monitored::Timer::m_stopTime
clock_type::time_point m_stopTime
Definition: MonitoredTimer.h:52
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
hist_file_dump.d
d
Definition: hist_file_dump.py:137
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
Monitored::IMonitoredVariable::IMonitoredVariable
IMonitoredVariable(std::string name)
Definition: IMonitoredVariable.h:27
python.handimod.now
now
Definition: handimod.py:675
Monitored::Timer::start
void start()
Definition: MonitoredTimer.h:64
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
Monitored::IMonitoredVariable::name
const std::string & name() const
Definition: IMonitoredVariable.h:19
Monitored::IMonitoredVariable::m_name
const std::string m_name
Definition: IMonitoredVariable.h:31
Monitored::Timer::m_startTime
clock_type::time_point m_startTime
Definition: MonitoredTimer.h:51
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32