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 () 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 33 of file AlgorithmTimerWrapper.cxx.

35 : m_algorithm (std::move (val_algorithm))
36 {
37 RCU_NEW_INVARIANT (this);
38 }
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
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 159 of file AlgorithmTimerWrapper.cxx.

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

◆ endInputFile()

StatusCode EL::AlgorithmTimerWrapper::endInputFile ( )
overridevirtual

call endInputFile on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 174 of file AlgorithmTimerWrapper.cxx.

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

◆ execute()

StatusCode EL::AlgorithmTimerWrapper::execute ( )
overridevirtual

call execute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 95 of file AlgorithmTimerWrapper.cxx.

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

◆ fileExecute()

StatusCode EL::AlgorithmTimerWrapper::fileExecute ( )
overridevirtual

call fileExecute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 144 of file AlgorithmTimerWrapper.cxx.

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

◆ finalize()

StatusCode EL::AlgorithmTimerWrapper::finalize ( )
overridevirtual

call finalize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 125 of file AlgorithmTimerWrapper.cxx.

127 {
128 using namespace msgEventLoop;
130
131 auto start = clock_type::now();
132 auto result = m_algorithm->finalize ();
133 auto stop = clock_type::now();
135 auto seconds = std::chrono::duration<float>(1);
136 std::ostringstream str;
137 str << std::setprecision(2) << std::fixed << "algorithm timer: " << m_algorithm->getName() << " " << (m_time_event/seconds) << " " << (m_time_file/seconds) << " " << (m_time_global/seconds);
138 ANA_MSG_INFO (str.str());
139 return result;
140 }
#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 71 of file AlgorithmTimerWrapper.cxx.

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

◆ getName()

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

Inherited Members

Implements EL::IAlgorithmWrapper.

Definition at line 42 of file AlgorithmTimerWrapper.cxx.

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

◆ hasName()

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

whether this algorithm has the given name

Implements EL::IAlgorithmWrapper.

Definition at line 51 of file AlgorithmTimerWrapper.cxx.

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

◆ initialize()

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

call initialize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 80 of file AlgorithmTimerWrapper.cxx.

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

◆ makeClone()

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

make a clone of this algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 60 of file AlgorithmTimerWrapper.cxx.

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

◆ postExecute()

StatusCode EL::AlgorithmTimerWrapper::postExecute ( )
overridevirtual

call postExecute on the algorithm

Reimplemented from EL::IAlgorithmWrapper.

Definition at line 110 of file AlgorithmTimerWrapper.cxx.

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

◆ testInvariant()

void EL::AlgorithmTimerWrapper::testInvariant ( ) const

test the invariant of this object

Definition at line 26 of file AlgorithmTimerWrapper.cxx.

28 {
29 }

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: