The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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.
 

Public Member Functions

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

Private Attributes

Stats_t m_stats
 statistics counter
 

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;
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198

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 }
A generic timer based on std::chrono and Gaudi::Accumulators.
Stats_t m_stats
statistics counter

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

Create (and start) a ScopeTimer.

Definition at line 90 of file GenericTimer.h.

90{ return ScopeTimer( m_stats ); }
A scoped timer that starts/stops on con/de-struction.

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