ATLAS Offline Software
Loading...
Searching...
No Matches
Monitored::Timer< unit > Class Template Reference

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)
virtual double get (size_t) const override
virtual std::string getString (size_t i) const override
virtual bool hasStringRepresentation () const override
 indcates that the stored content can be converted to strings
virtual size_t size () const override
 gives size of vector representation
const std::string & name () const

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.

61 start();
62 }
const std::string & name() const
A monitored timer.
void checkNamingConvention(std::string_view name)

◆ 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()

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

Implements Monitored::IMonitoredVariable.

Definition at line 44 of file MonitoredTimer.h.

44{ return {}; }

◆ 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 ( ) const

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

Definition at line 70 of file MonitoredTimer.h.

70 {
72 if (stopTime == clock_type::time_point()) // never stopped
75 return d.count();
76 }
clock_type::time_point m_startTime
clock_type::time_point m_stopTime

◆ 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: