| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Private Member Functions | Private Attributes | List of all members
Gaudi::Timers::GenericTimer< Clock, Unit >::ScopeTimer Class Reference

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

`#include <Gaudi/Timers/GenericTimer.h>`

## Public Member Functions
| ScopeTimer (Stats_t &stat)
| Start Scoped timer accumulating into stat. More...
| ~ScopeTimer ()
| Destructor stopping timer. More...
auto | elapsed () const
| Return the elapsed time without stopping the timer. More...

## Private Member Functions
void | stop () const
| Stop the timer, accumulate elapsed time and return current measurement. More...

## Private Attributes
Stats_t & | m_stats
| reference to statistics counter More...
Clock::time_point | m_t0
| start time of timer More...

## 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 41 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 44 of file GenericTimer.h.

44 : m_stats( stat ), m_t0( Clock::now() ) {}
Gaudi::Timers::GenericTimer::ScopeTimer::m_t0
Clock::time_point m_t0
start time of timer
Definition: GenericTimer.h:64
Gaudi::Timers::GenericTimer::ScopeTimer::m_stats
Stats_t & m_stats
reference to statistics counter
Definition: GenericTimer.h:63

## ◆ ~ScopeTimer()

template<typename Clock , typename Unit >

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

Destructor stopping timer.

Definition at line 47 of file GenericTimer.h.

47 { stop(); }
Gaudi::Timers::GenericTimer::ScopeTimer::stop
void stop() const
Stop the timer, accumulate elapsed time and return current measurement.
Definition: GenericTimer.h:61

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

51 {
52 // Fenced according to https://codereview.stackexchange.com/q/196245
53 std::atomic_thread_fence( std::memory_order_relaxed );
54 auto dt = Clock::now() - m_t0;
55 std::atomic_thread_fence( std::memory_order_relaxed );
56 return std::chrono::duration_cast<Unit>( dt );
57 }
Gaudi::Timers::GenericTimer::ScopeTimer::m_t0
Clock::time_point m_t0
start time of timer
Definition: GenericTimer.h:64
std::atomic_thread_fence
T atomic_thread_fence(T... args)

## ◆ stop()

template<typename Clock , typename Unit >

void Gaudi::Timers::GenericTimer< Clock, Unit >::ScopeTimer::stop | ( |  | ) | const
| inline private

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

Definition at line 61 of file GenericTimer.h.

61 { m_stats += elapsed(); }
Gaudi::Timers::GenericTimer::ScopeTimer::elapsed
auto elapsed() const
Return the elapsed time without stopping the timer.
Definition: GenericTimer.h:51
Gaudi::Timers::GenericTimer::ScopeTimer::m_stats
Stats_t & m_stats
reference to statistics counter
Definition: GenericTimer.h:63

## 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 63 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 64 of file GenericTimer.h.

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

- GaudiKernel/Gaudi/Timers/GenericTimer.h