The Gaudi Framework  v32r2 (46d42edc)
Gaudi::Timers::GenericTimer< Clock, Unit > Class Template Reference

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

#include <Gaudi/Timers/GenericTimer.h>

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 33 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 36 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 72 of file GenericTimer.h.

72  {
73  o->declareCounter( name, m_stats );
74  }
Stats_t m_stats
statistics counter
Definition: GenericTimer.h:86

◆ 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 80 of file GenericTimer.h.

80 { return ScopeTimer( m_stats ); }
Stats_t m_stats
statistics counter
Definition: GenericTimer.h:86

◆ stats()

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

Return accumulated timing statistics.

Definition at line 83 of file GenericTimer.h.

83 { return m_stats; }
Stats_t m_stats
statistics counter
Definition: GenericTimer.h:86

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 86 of file GenericTimer.h.


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