ATLAS Offline Software
Loading...
Searching...
No Matches
EL::AlgorithmTimerWrapper Class Referencefinal

an IAlgorithmWrapper that adds a timer to an algorithm More...

#include <AlgorithmTimerWrapper.h>

Inheritance diagram for EL::AlgorithmTimerWrapper:
Collaboration diagram for EL::AlgorithmTimerWrapper:

Public Types

using clock_type = std::chrono::high_resolution_clock
 the clock we use for our timer

Public Member Functions

void testInvariant () const
 test the invariant of this object
 AlgorithmTimerWrapper ()
 standard default constructor for serialization
 AlgorithmTimerWrapper (std::unique_ptr< IAlgorithmWrapper > &&val_algorithm)
 standard constructor
virtual std::string_view getName () const override
virtual bool hasName (const std::string &name) const override
 whether this algorithm has the given name
virtual std::unique_ptr< IAlgorithmWrappermakeClone () const override
 make a clone of this algorithm
virtual AlgorithmgetLegacyAlg () override
 get the legacy algorithm, if we wrap one
virtual StatusCode initialize (const AlgorithmWorkerData &workerData) override
 call initialize on the algorithm
virtual StatusCode execute (const EventContext &ctx) override
 call execute on the algorithm
virtual StatusCode postExecute () override
 call postExecute on the algorithm
virtual StatusCode finalize () override
 call finalize on the algorithm
virtual::StatusCode fileExecute () override
 call fileExecute on the algorithm
virtual::StatusCode beginInputFile () override
 call beginInputFile on the algorithm
virtual::StatusCode endInputFile () override
 call endInputFile on the algorithm

Private Attributes

std::unique_ptr< IAlgorithmWrapperm_algorithm
 the actual algorithm
clock_type::duration m_time_global {}
 the timers for different calls
clock_type::duration m_time_file {}
clock_type::duration m_time_event {}

Detailed Description

an IAlgorithmWrapper that adds a timer to an algorithm

Note
There is a dedicated test in AnalysisAlgorithms config that runs a test job with this module enabled to ensure it runs and doesn't break the output.

Definition at line 26 of file AlgorithmTimerWrapper.h.

Member Typedef Documentation

◆ clock_type

using EL::AlgorithmTimerWrapper::clock_type = std::chrono::high_resolution_clock

the clock we use for our timer

Public Members

Definition at line 34 of file AlgorithmTimerWrapper.h.

Constructor & Destructor Documentation

◆ AlgorithmTimerWrapper() [1/2]

EL::AlgorithmTimerWrapper::AlgorithmTimerWrapper ( )
inline

standard default constructor for serialization

Definition at line 40 of file AlgorithmTimerWrapper.h.

40{};

◆ AlgorithmTimerWrapper() [2/2]

EL::AlgorithmTimerWrapper::AlgorithmTimerWrapper ( std::unique_ptr< IAlgorithmWrapper > && val_algorithm)

standard constructor

Definition at line 34 of file AlgorithmTimerWrapper.cxx.

36 : m_algorithm (std::move (val_algorithm))
37 {
38 RCU_NEW_INVARIANT (this);
39 }
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
std::unique_ptr< IAlgorithmWrapper > m_algorithm
the actual algorithm

Member Function Documentation

◆ beginInputFile()

StatusCode EL::AlgorithmTimerWrapper::beginInputFile ( )
overridevirtual

call beginInputFile on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 160 of file AlgorithmTimerWrapper.cxx.

162 {
163 using namespace msgEventLoop;
165
166 auto start = clock_type::now();
167 auto result = m_algorithm->beginInputFile ();
168 auto stop = clock_type::now();
170 return result;
171 }
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:219
clock_type::duration m_time_file

◆ endInputFile()

StatusCode EL::AlgorithmTimerWrapper::endInputFile ( )
overridevirtual

call endInputFile on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 175 of file AlgorithmTimerWrapper.cxx.

177 {
178 using namespace msgEventLoop;
180
181 auto start = clock_type::now();
182 auto result = m_algorithm->endInputFile ();
183 auto stop = clock_type::now();
185 return result;
186 }

◆ execute()

StatusCode EL::AlgorithmTimerWrapper::execute ( const EventContext & ctx)
overridevirtual

call execute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 96 of file AlgorithmTimerWrapper.cxx.

98 {
99 using namespace msgEventLoop;
101
102 auto start = clock_type::now();
103 auto result = m_algorithm->execute (ctx);
104 auto stop = clock_type::now();
106 return result;
107 }
clock_type::duration m_time_event

◆ fileExecute()

StatusCode EL::AlgorithmTimerWrapper::fileExecute ( )
overridevirtual

call fileExecute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 145 of file AlgorithmTimerWrapper.cxx.

147 {
148 using namespace msgEventLoop;
150
151 auto start = clock_type::now();
152 auto result = m_algorithm->fileExecute ();
153 auto stop = clock_type::now();
155 return result;
156 }

◆ finalize()

StatusCode EL::AlgorithmTimerWrapper::finalize ( )
overridevirtual

call finalize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 126 of file AlgorithmTimerWrapper.cxx.

128 {
129 using namespace msgEventLoop;
131
132 auto start = clock_type::now();
133 auto result = m_algorithm->finalize ();
134 auto stop = clock_type::now();
136 auto seconds = std::chrono::duration<float>(1);
137 std::ostringstream str;
138 str << std::setprecision(2) << std::fixed << "algorithm timer: " << m_algorithm->getName() << " " << (m_time_event/seconds) << " " << (m_time_file/seconds) << " " << (m_time_global/seconds);
139 ANA_MSG_INFO (str.str());
140 return result;
141 }
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
clock_type::duration m_time_global
the timers for different calls

◆ getLegacyAlg()

Algorithm * EL::AlgorithmTimerWrapper::getLegacyAlg ( )
overridevirtual

get the legacy algorithm, if we wrap one

Reimplemented from EL::IAlgorithmWrapper.

Definition at line 72 of file AlgorithmTimerWrapper.cxx.

74 {
75 RCU_READ_INVARIANT (this);
76 return m_algorithm->getLegacyAlg();
77 }
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217

◆ getName()

std::string_view EL::AlgorithmTimerWrapper::getName ( ) const
overridevirtual

Inherited Members

Implements EL::IAlgorithmWrapper.

Definition at line 43 of file AlgorithmTimerWrapper.cxx.

45 {
46 RCU_READ_INVARIANT (this);
47 return m_algorithm->getName();
48 }

◆ hasName()

bool EL::AlgorithmTimerWrapper::hasName ( const std::string & name) const
overridevirtual

whether this algorithm has the given name

Implements EL::IAlgorithmWrapper.

Definition at line 52 of file AlgorithmTimerWrapper.cxx.

54 {
55 RCU_READ_INVARIANT (this);
56 return m_algorithm->hasName (name);
57 }

◆ initialize()

StatusCode EL::AlgorithmTimerWrapper::initialize ( const AlgorithmWorkerData & workerData)
overridevirtual

call initialize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 81 of file AlgorithmTimerWrapper.cxx.

83 {
84 using namespace msgEventLoop;
86
87 auto start = clock_type::now();
88 auto result = m_algorithm->initialize (workerData);
89 auto stop = clock_type::now();
91 return result;
92 }

◆ makeClone()

std::unique_ptr< IAlgorithmWrapper > EL::AlgorithmTimerWrapper::makeClone ( ) const
overridevirtual

make a clone of this algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 61 of file AlgorithmTimerWrapper.cxx.

63 {
64 using namespace msgEventLoop;
65 RCU_READ_INVARIANT (this);
66
67 return std::make_unique<AlgorithmTimerWrapper> (m_algorithm->makeClone());
68 }

◆ postExecute()

StatusCode EL::AlgorithmTimerWrapper::postExecute ( )
overridevirtual

call postExecute on the algorithm

Reimplemented from EL::IAlgorithmWrapper.

Definition at line 111 of file AlgorithmTimerWrapper.cxx.

113 {
114 using namespace msgEventLoop;
116
117 auto start = clock_type::now();
118 auto result = m_algorithm->postExecute ();
119 auto stop = clock_type::now();
121 return result;
122 }

◆ testInvariant()

void EL::AlgorithmTimerWrapper::testInvariant ( ) const

test the invariant of this object

Definition at line 27 of file AlgorithmTimerWrapper.cxx.

29 {
30 }

Member Data Documentation

◆ m_algorithm

std::unique_ptr<IAlgorithmWrapper> EL::AlgorithmTimerWrapper::m_algorithm
private

the actual algorithm

Private Members

Definition at line 82 of file AlgorithmTimerWrapper.h.

◆ m_time_event

clock_type::duration EL::AlgorithmTimerWrapper::m_time_event {}
private

Definition at line 87 of file AlgorithmTimerWrapper.h.

87{};

◆ m_time_file

clock_type::duration EL::AlgorithmTimerWrapper::m_time_file {}
private

Definition at line 86 of file AlgorithmTimerWrapper.h.

86{};

◆ m_time_global

clock_type::duration EL::AlgorithmTimerWrapper::m_time_global {}
private

the timers for different calls

Definition at line 85 of file AlgorithmTimerWrapper.h.

85{};

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