ATLAS Offline Software
Loading...
Searching...
No Matches
TrigTimeStamp Class Reference

utility class to measure time duration in AthenaMT The pattern when it is useful: AlgA tags the beginning of the time period AlgA::execute() { timeStampHandle.record( std::move( std::make_unique<TrigTimeStamp>() ) ); } More...

#include <TrigTimeStamp.h>

Collaboration diagram for TrigTimeStamp:

Public Types

typedef std::chrono::high_resolution_clock::time_point stamp_type

Public Member Functions

 TrigTimeStamp ()
 Default constructor, sets to now.
TrigTimeStampoperator= (const TrigTimeStamp &)=default
 Automatic copy assignemnt operator.
 TrigTimeStamp (const TrigTimeStamp &)=default
 Automatic copy constructor.
double millisecondsSince () const
double millisecondsDifference (const TrigTimeStamp &other) const
uint64_t microsecondsSinceEpoch () const
stamp_type get () const
 Obtain the stamp value.
void set (stamp_type time=std::chrono::high_resolution_clock::now())
 Update the stamp value.

Private Attributes

stamp_type m_stamp

Detailed Description

utility class to measure time duration in AthenaMT The pattern when it is useful: AlgA tags the beginning of the time period AlgA::execute() { timeStampHandle.record( std::move( std::make_unique<TrigTimeStamp>() ) ); }

AlgB obtains the duration since the start tagged in AlgA: AlgB::execute() { double duration = timeStampHandle.cptr().millisecondsSince(); }

Definition at line 23 of file TrigTimeStamp.h.

Member Typedef Documentation

◆ stamp_type

typedef std::chrono::high_resolution_clock::time_point TrigTimeStamp::stamp_type

Definition at line 25 of file TrigTimeStamp.h.

Constructor & Destructor Documentation

◆ TrigTimeStamp() [1/2]

TrigTimeStamp::TrigTimeStamp ( )
inline

Default constructor, sets to now.

Definition at line 76 of file TrigTimeStamp.h.

76{ set(); }
void set(stamp_type time=std::chrono::high_resolution_clock::now())
Update the stamp value.

◆ TrigTimeStamp() [2/2]

TrigTimeStamp::TrigTimeStamp ( const TrigTimeStamp & )
default

Automatic copy constructor.

Member Function Documentation

◆ get()

TrigTimeStamp::stamp_type TrigTimeStamp::get ( ) const
inline

Obtain the stamp value.

Definition at line 78 of file TrigTimeStamp.h.

78{ return m_stamp; }
stamp_type m_stamp

◆ microsecondsSinceEpoch()

uint64_t TrigTimeStamp::microsecondsSinceEpoch ( ) const
Returns
The time duration between when the time stamp was created and the epoch

Definition at line 15 of file TrigTimeStamp.cxx.

15 {
16 // Note: A uint64_t at microsecond precision has capacity of ~585,000 years
17 uint64_t microsecondsSinceEpoch = std::chrono::duration_cast<std::chrono::microseconds>( m_stamp.time_since_epoch() ).count();
19}
uint64_t microsecondsSinceEpoch() const

◆ millisecondsDifference()

double TrigTimeStamp::millisecondsDifference ( const TrigTimeStamp & other) const
Returns
The time duration between when this and another time stamp were created, or last set
Parameters
[in]otherTime stamp to compare this one to

Definition at line 11 of file TrigTimeStamp.cxx.

11 {
12 return std::chrono::duration_cast<std::chrono::milliseconds>( other.get() - m_stamp ).count();
13}

◆ millisecondsSince()

double TrigTimeStamp::millisecondsSince ( ) const
Returns
The time duration between now and when the time stamp was created

Definition at line 7 of file TrigTimeStamp.cxx.

7 {
8 return std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::high_resolution_clock::now() - m_stamp ).count();
9}

◆ operator=()

TrigTimeStamp & TrigTimeStamp::operator= ( const TrigTimeStamp & )
default

Automatic copy assignemnt operator.

◆ set()

void TrigTimeStamp::set ( TrigTimeStamp::stamp_type time = std::chrono::high_resolution_clock::now())
inline

Update the stamp value.

Parameters
[in]timeTime to set. Default is now.

Definition at line 80 of file TrigTimeStamp.h.

80{ m_stamp = time; }
time(flags, cells_name, *args, **kw)

Member Data Documentation

◆ m_stamp

stamp_type TrigTimeStamp::m_stamp
private

Definition at line 70 of file TrigTimeStamp.h.


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