The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::Timers::GenericTimer< Clock, Unit >::ScopeTimer Class Reference

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

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

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

Public Member Functions

 ScopeTimer (Stats_t &stat)
 Start Scoped timer accumulating into stat.
 ~ScopeTimer ()
 Destructor stopping timer.
auto elapsed () const
 Return the elapsed time without stopping the timer.

Private Member Functions

void stop () const
 Stop the timer, accumulate elapsed time and return current measurement.

Private Attributes

Stats_t & m_stats
 reference to statistics counter
Clock::time_point m_t0
 start time of timer

Detailed Description

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

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

Definition at line 51 of file GenericTimer.h.

Constructor & Destructor Documentation

◆ ScopeTimer()

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

Start Scoped timer accumulating into stat.

Definition at line 54 of file GenericTimer.h.

54: m_stats( stat ), m_t0( Clock::now() ) {}
Clock::time_point m_t0
start time of timer
Stats_t & m_stats
reference to statistics counter
A generic timer based on std::chrono and Gaudi::Accumulators.

◆ ~ScopeTimer()

template<typename Clock, typename Unit>
Gaudi::Timers::GenericTimer< Clock, Unit >::ScopeTimer::~ScopeTimer ( )
inline

Destructor stopping timer.

Definition at line 57 of file GenericTimer.h.

57{ stop(); }
void stop() const
Stop the timer, accumulate elapsed time and return current measurement.

Member Function Documentation

◆ elapsed()

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

Return the elapsed time without stopping the timer.

Returns
std::chrono::duration<Unit>

Definition at line 61 of file GenericTimer.h.

61 {
62 // Fenced according to https://codereview.stackexchange.com/q/196245
64 auto dt = Clock::now() - m_t0;
67 }

◆ stop()

template<typename Clock, typename Unit>
void Gaudi::Timers::GenericTimer< Clock, Unit >::ScopeTimer::stop ( ) const
inlineprivate

Stop the timer, accumulate elapsed time and return current measurement.

Definition at line 71 of file GenericTimer.h.

71{ m_stats += elapsed(); }
auto elapsed() const
Return the elapsed time without stopping the timer.

Member Data Documentation

◆ m_stats

template<typename Clock, typename Unit>
Stats_t& Gaudi::Timers::GenericTimer< Clock, Unit >::ScopeTimer::m_stats
private

reference to statistics counter

Definition at line 73 of file GenericTimer.h.

◆ m_t0

template<typename Clock, typename Unit>
Clock::time_point Gaudi::Timers::GenericTimer< Clock, Unit >::ScopeTimer::m_t0
private

start time of timer

Definition at line 74 of file GenericTimer.h.


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