ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
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 More...
 

Public Member Functions

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

Private Attributes

std::unique_ptr< IAlgorithmWrapperm_algorithm
 the actual algorithm More...
 
clock_type::duration m_time_global {}
 the timers for different calls More...
 
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  }

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;
163  RCU_CHANGE_INVARIANT (this);
164 
165  auto start = clock_type::now();
166  auto result = m_algorithm->beginInputFile ();
167  auto stop = clock_type::now();
168  m_time_file += stop - start;
169  return result;
170  }

◆ 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;
178  RCU_CHANGE_INVARIANT (this);
179 
180  auto start = clock_type::now();
181  auto result = m_algorithm->endInputFile ();
182  auto stop = clock_type::now();
183  m_time_file += stop - start;
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;
99  RCU_CHANGE_INVARIANT (this);
100 
101  auto start = clock_type::now();
102  auto result = m_algorithm->execute ();
103  auto stop = clock_type::now();
104  m_time_event += stop - start;
105  return result;
106  }

◆ 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;
148  RCU_CHANGE_INVARIANT (this);
149 
150  auto start = clock_type::now();
151  auto result = m_algorithm->fileExecute ();
152  auto stop = clock_type::now();
153  m_time_file += stop - start;
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;
129  RCU_CHANGE_INVARIANT (this);
130 
131  auto start = clock_type::now();
132  auto result = m_algorithm->finalize ();
133  auto stop = clock_type::now();
134  m_time_global += stop - start;
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  }

◆ 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  }

◆ 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;
84  RCU_CHANGE_INVARIANT (this);
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;
114  RCU_CHANGE_INVARIANT (this);
115 
116  auto start = clock_type::now();
117  auto result = m_algorithm->postExecute ();
118  auto stop = clock_type::now();
119  m_time_event += stop - start;
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.

◆ m_time_file

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

Definition at line 86 of file AlgorithmTimerWrapper.h.

◆ 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.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
EL::AlgorithmTimerWrapper::m_algorithm
std::unique_ptr< IAlgorithmWrapper > m_algorithm
the actual algorithm
Definition: AlgorithmTimerWrapper.h:82
python.handimod.now
now
Definition: handimod.py:675
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
python.LArCalib_HVCorrConfig.seconds
seconds
Definition: LArCalib_HVCorrConfig.py:86
EL::AlgorithmTimerWrapper::m_time_file
clock_type::duration m_time_file
Definition: AlgorithmTimerWrapper.h:86
EL::AlgorithmTimerWrapper::m_time_global
clock_type::duration m_time_global
the timers for different calls
Definition: AlgorithmTimerWrapper.h:85
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
EL::AlgorithmTimerWrapper::m_time_event
clock_type::duration m_time_event
Definition: AlgorithmTimerWrapper.h:87
str
Definition: BTagTrackIpAccessor.cxx:11
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233