CbmRoot
Loading...
Searching...
No Matches
cbm::algo::ca::Timer Class Reference

A timer class for the monitor. More...

#include <CaTimer.h>

Public Types

using Clock = std::chrono::high_resolution_clock
 
using Duration = std::chrono::nanoseconds
 
using DurationCount = Duration::rep
 
using TimePoint = std::chrono::time_point<Clock, Duration>
 

Public Member Functions

 Timer ()=default
 Default constructor.
 
 ~Timer ()=default
 Destructor.
 
 Timer (const Timer &)=default
 Copy constructor.
 
 Timer (Timer &&)=default
 Move constructor.
 
Timeroperator= (const Timer &)=default
 Copy assignment operator.
 
Timeroperator= (Timer &&)=default
 Move assignment operator.
 
void AddTimer (const Timer &other, bool parallel)
 Adds another timer.
 
double GetAverage () const
 Gets average time [s].
 
double GetMax () const
 Gets time of the longest call [s].
 
double GetMin () const
 Gets time of the shortest call [s].
 
int GetNofCalls () const
 Gets number of calls.
 
int GetMaxCallIndex () const
 Gets index of the longest call.
 
int GetMinCallIndex () const
 Gets index of the longest call.
 
double GetTotal () const
 Gets total time [s].
 
double GetTotalMs () const
 Gets total time [ms].
 
void Reset ()
 Resets the timer.
 
void Start ()
 Starts the timer.
 
void Stop ()
 Stops the timer.
 

Private Member Functions

template<typename Archive >
void serialize (Archive &ar, const unsigned int)
 

Private Attributes

TimePoint fStart = TimePoint()
 
DurationCount fMin = std::numeric_limits<DurationCount>::max()
 Minimal time period.
 
DurationCount fMax = std::numeric_limits<DurationCount>::min()
 Maximal time period.
 
DurationCount fTotal = DurationCount(0)
 Total measured time period [ns].
 
int fNofCalls = 0
 Number of timer calls [ns].
 
int fMinCallIndex = -1
 Index of the shortest call [ns].
 
int fMaxCallIndex = -1
 Index of the longest call [ns].
 

Friends

class boost::serialization::access
 

Detailed Description

A timer class for the monitor.

Definition at line 25 of file CaTimer.h.

Member Typedef Documentation

◆ Clock

using cbm::algo::ca::Timer::Clock = std::chrono::high_resolution_clock

Definition at line 27 of file CaTimer.h.

◆ Duration

using cbm::algo::ca::Timer::Duration = std::chrono::nanoseconds

Definition at line 28 of file CaTimer.h.

◆ DurationCount

using cbm::algo::ca::Timer::DurationCount = Duration::rep

Definition at line 29 of file CaTimer.h.

◆ TimePoint

using cbm::algo::ca::Timer::TimePoint = std::chrono::time_point<Clock, Duration>

Definition at line 30 of file CaTimer.h.

Constructor & Destructor Documentation

◆ Timer() [1/3]

cbm::algo::ca::Timer::Timer ( )
default

Default constructor.

◆ ~Timer()

cbm::algo::ca::Timer::~Timer ( )
default

Destructor.

◆ Timer() [2/3]

cbm::algo::ca::Timer::Timer ( const Timer & )
default

Copy constructor.

◆ Timer() [3/3]

cbm::algo::ca::Timer::Timer ( Timer && )
default

Move constructor.

Member Function Documentation

◆ AddTimer()

void cbm::algo::ca::Timer::AddTimer ( const Timer & other,
bool parallel )
inline

Adds another timer.

Parameters
otherReference to the other Timer object to add
parallelBool: if the timers were executed in parallel

If the parallel flag is true then the resulting fTotal time is taken as a maximum of each total time of the appended timers. If the parallel flag is false, the resulting fTotal is a sum of all timers.

Definition at line 120 of file CaTimer.h.

References fMax, fMaxCallIndex, fMin, fMinCallIndex, fNofCalls, and fTotal.

◆ GetAverage()

double cbm::algo::ca::Timer::GetAverage ( ) const
inline

Gets average time [s].

Definition at line 59 of file CaTimer.h.

References fNofCalls, and fTotal.

Referenced by cbm::algo::ca::Monitor< ECounterKey, ETimerKey >::ToString().

◆ GetMax()

double cbm::algo::ca::Timer::GetMax ( ) const
inline

Gets time of the longest call [s].

Definition at line 62 of file CaTimer.h.

References fMax.

Referenced by cbm::algo::ca::Monitor< ECounterKey, ETimerKey >::ToString().

◆ GetMaxCallIndex()

int cbm::algo::ca::Timer::GetMaxCallIndex ( ) const
inline

Gets index of the longest call.

Definition at line 71 of file CaTimer.h.

References fMaxCallIndex.

◆ GetMin()

double cbm::algo::ca::Timer::GetMin ( ) const
inline

Gets time of the shortest call [s].

Definition at line 65 of file CaTimer.h.

References fMin.

Referenced by cbm::algo::ca::Monitor< ECounterKey, ETimerKey >::ToString().

◆ GetMinCallIndex()

int cbm::algo::ca::Timer::GetMinCallIndex ( ) const
inline

Gets index of the longest call.

Definition at line 74 of file CaTimer.h.

References fMinCallIndex.

◆ GetNofCalls()

int cbm::algo::ca::Timer::GetNofCalls ( ) const
inline

Gets number of calls.

Definition at line 68 of file CaTimer.h.

References fNofCalls.

Referenced by cbm::algo::ca::Monitor< ECounterKey, ETimerKey >::ToString().

◆ GetTotal()

double cbm::algo::ca::Timer::GetTotal ( ) const
inline

Gets total time [s].

Definition at line 77 of file CaTimer.h.

References fTotal.

Referenced by GetTotalMs(), cbm::algo::TrackingChain::PrepareOutput(), and cbm::algo::ca::Monitor< ECounterKey, ETimerKey >::ToString().

◆ GetTotalMs()

double cbm::algo::ca::Timer::GetTotalMs ( ) const
inline

Gets total time [ms].

Definition at line 80 of file CaTimer.h.

References GetTotal().

Referenced by cbm::algo::Reco::QueueTrackingMetrics().

◆ operator=() [1/2]

Timer & cbm::algo::ca::Timer::operator= ( const Timer & )
default

Copy assignment operator.

◆ operator=() [2/2]

Timer & cbm::algo::ca::Timer::operator= ( Timer && )
default

Move assignment operator.

◆ Reset()

void cbm::algo::ca::Timer::Reset ( )
inline

Resets the timer.

Definition at line 143 of file CaTimer.h.

References fMax, fMaxCallIndex, fMin, fMinCallIndex, fNofCalls, fStart, and fTotal.

◆ serialize()

template<typename Archive >
void cbm::algo::ca::Timer::serialize ( Archive & ar,
const unsigned int  )
inlineprivate

Definition at line 94 of file CaTimer.h.

References fMax, fMaxCallIndex, fMin, fMinCallIndex, fNofCalls, and fTotal.

◆ Start()

void cbm::algo::ca::Timer::Start ( )
inline

Starts the timer.

Definition at line 86 of file CaTimer.h.

References fStart.

Referenced by cbm::algo::ca::TrackFinder::FindTracksThread().

◆ Stop()

void cbm::algo::ca::Timer::Stop ( )
inline

Stops the timer.

Definition at line 156 of file CaTimer.h.

References fMax, fMaxCallIndex, fMin, fMinCallIndex, fNofCalls, fStart, and fTotal.

Friends And Related Symbol Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 92 of file CaTimer.h.

Member Data Documentation

◆ fMax

DurationCount cbm::algo::ca::Timer::fMax = std::numeric_limits<DurationCount>::min()
private

Maximal time period.

Definition at line 106 of file CaTimer.h.

Referenced by AddTimer(), GetMax(), Reset(), serialize(), and Stop().

◆ fMaxCallIndex

int cbm::algo::ca::Timer::fMaxCallIndex = -1
private

Index of the longest call [ns].

Definition at line 110 of file CaTimer.h.

Referenced by AddTimer(), GetMaxCallIndex(), Reset(), serialize(), and Stop().

◆ fMin

DurationCount cbm::algo::ca::Timer::fMin = std::numeric_limits<DurationCount>::max()
private

Minimal time period.

Definition at line 105 of file CaTimer.h.

Referenced by AddTimer(), GetMin(), Reset(), serialize(), and Stop().

◆ fMinCallIndex

int cbm::algo::ca::Timer::fMinCallIndex = -1
private

Index of the shortest call [ns].

Definition at line 109 of file CaTimer.h.

Referenced by AddTimer(), GetMinCallIndex(), Reset(), serialize(), and Stop().

◆ fNofCalls

int cbm::algo::ca::Timer::fNofCalls = 0
private

Number of timer calls [ns].

Definition at line 108 of file CaTimer.h.

Referenced by AddTimer(), GetAverage(), GetNofCalls(), Reset(), serialize(), and Stop().

◆ fStart

TimePoint cbm::algo::ca::Timer::fStart = TimePoint()
private

Definition at line 104 of file CaTimer.h.

Referenced by Reset(), Start(), and Stop().

◆ fTotal

DurationCount cbm::algo::ca::Timer::fTotal = DurationCount(0)
private

Total measured time period [ns].

Definition at line 107 of file CaTimer.h.

Referenced by AddTimer(), GetAverage(), GetTotal(), Reset(), serialize(), and Stop().


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