The Gaudi Framework  master (37c0b60a)
Gaudi::Timers::GenericTimer< Clock, Unit > Class Template Reference

A generic timer based on std::chrono and Gaudi::Accumulators. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Timers/GenericTimer.h>

Collaboration diagram for Gaudi::Timers::GenericTimer< Clock, Unit >:

Classes

class  ScopeTimer
 A scoped timer that starts/stops on con/de-struction. More...
 

Public Types

typedef Gaudi::Accumulators::StatCounter< Unit > Stats_t
 Type of Counter used for accumulating time measurements. More...
 

Public Member Functions

 GenericTimer ()=default
 Default constructor. More...
 
template<class OWNER >
 GenericTimer (OWNER *o, const std::string &name)
 Constructor attaching the statistics counter to an owner. More...
 
 GenericTimer (const GenericTimer &)=delete
 No copy. More...
 
auto operator() () const
 Create (and start) a ScopeTimer. More...
 
const Stats_tstats () const
 Return accumulated timing statistics. More...
 

Private Attributes

Stats_t m_stats
 statistics counter More...
 

Detailed Description

template<typename Clock, typename Unit>
class Gaudi::Timers::GenericTimer< Clock, Unit >

A generic timer based on std::chrono and Gaudi::Accumulators.

The timer is templated with a std::chrono compatible clock and the Unit of precision (ms, us, ...). It accumulates all time measurements in a Gaudi::Accumulators::StatCounter. A time measurement is done via the RAII helper class created by calling operator().

Usually one would use one of the predefined Timer types from Gaudi/Timers.h:

// .h
Gaudi::Timer m_timer;
// .cpp
{
auto timeit = m_timer();
// code to be timed
}
info() << m_timer.stats() << endmsg;

Definition at line 43 of file GenericTimer.h.

Member Typedef Documentation

◆ Stats_t

template<typename Clock , typename Unit >
typedef Gaudi::Accumulators::StatCounter<Unit> Gaudi::Timers::GenericTimer< Clock, Unit >::Stats_t

Type of Counter used for accumulating time measurements.

Definition at line 46 of file GenericTimer.h.

Constructor & Destructor Documentation

◆ GenericTimer() [1/3]

template<typename Clock , typename Unit >
Gaudi::Timers::GenericTimer< Clock, Unit >::GenericTimer ( )
default

Default constructor.

◆ GenericTimer() [2/3]

template<typename Clock , typename Unit >
template<class OWNER >
Gaudi::Timers::GenericTimer< Clock, Unit >::GenericTimer ( OWNER *  o,
const std::string name 
)
inline

Constructor attaching the statistics counter to an owner.

Definition at line 82 of file GenericTimer.h.

82  {
83  o->declareCounter( name, std::string{ "timer:" } + typeid( Unit::rep ).name(), m_stats );
84  }

◆ GenericTimer() [3/3]

template<typename Clock , typename Unit >
Gaudi::Timers::GenericTimer< Clock, Unit >::GenericTimer ( const GenericTimer< Clock, Unit > &  )
delete

No copy.

Member Function Documentation

◆ operator()()

template<typename Clock , typename Unit >
auto Gaudi::Timers::GenericTimer< Clock, Unit >::operator() ( ) const
inline

Create (and start) a ScopeTimer.

Definition at line 90 of file GenericTimer.h.

90 { return ScopeTimer( m_stats ); }

◆ stats()

template<typename Clock , typename Unit >
const Stats_t& Gaudi::Timers::GenericTimer< Clock, Unit >::stats ( ) const
inline

Return accumulated timing statistics.

Definition at line 93 of file GenericTimer.h.

93 { return m_stats; }

Member Data Documentation

◆ m_stats

template<typename Clock , typename Unit >
Stats_t Gaudi::Timers::GenericTimer< Clock, Unit >::m_stats
mutableprivate

statistics counter

Definition at line 96 of file GenericTimer.h.


The documentation for this class was generated from the following file:
std::string
STL class.
Gaudi::Timer
Timers::GenericTimer< std::chrono::high_resolution_clock, std::chrono::microseconds > Timer
Default timer using a standard clock with microsecond precision.
Definition: Timers.h:26
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::Timers::GenericTimer::m_stats
Stats_t m_stats
statistics counter
Definition: GenericTimer.h:96