ATLAS Offline Software
Loading...
Searching...
No Matches
AlgorithmTimerWrapper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
17#include <iomanip>
18#include <ios>
19
20//
21// method implementations
22//
23
24namespace EL
25{
26 void AlgorithmTimerWrapper ::
27 testInvariant () const
28 {
29 }
30
31
32
33 AlgorithmTimerWrapper ::
34 AlgorithmTimerWrapper (std::unique_ptr<IAlgorithmWrapper>&& val_algorithm)
35 : m_algorithm (std::move (val_algorithm))
36 {
37 RCU_NEW_INVARIANT (this);
38 }
39
40
41
42 std::string_view AlgorithmTimerWrapper ::
43 getName () const
44 {
45 RCU_READ_INVARIANT (this);
46 return m_algorithm->getName();
47 }
48
49
50
51 bool AlgorithmTimerWrapper ::
52 hasName (const std::string& name) const
53 {
54 RCU_READ_INVARIANT (this);
55 return m_algorithm->hasName (name);
56 }
57
58
59
60 std::unique_ptr<IAlgorithmWrapper> AlgorithmTimerWrapper ::
61 makeClone() const
62 {
63 using namespace msgEventLoop;
64 RCU_READ_INVARIANT (this);
65
66 return std::make_unique<AlgorithmTimerWrapper> (m_algorithm->makeClone());
67 }
68
69
70
71 Algorithm *AlgorithmTimerWrapper ::
72 getLegacyAlg ()
73 {
74 RCU_READ_INVARIANT (this);
75 return m_algorithm->getLegacyAlg();
76 }
77
78
79
80 StatusCode AlgorithmTimerWrapper ::
81 initialize (const AlgorithmWorkerData& workerData)
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();
89 m_time_global += stop - start;
90 return result;
91 }
92
93
94
95 StatusCode AlgorithmTimerWrapper ::
96 execute ()
97 {
98 using namespace msgEventLoop;
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 }
107
108
109
110 StatusCode AlgorithmTimerWrapper ::
111 postExecute ()
112 {
113 using namespace msgEventLoop;
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 }
122
123
124
125 StatusCode AlgorithmTimerWrapper ::
126 finalize ()
127 {
128 using namespace msgEventLoop;
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 }
141
142
143
144 ::StatusCode AlgorithmTimerWrapper ::
145 fileExecute ()
146 {
147 using namespace msgEventLoop;
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 }
156
157
158
159 ::StatusCode AlgorithmTimerWrapper ::
160 beginInputFile ()
161 {
162 using namespace msgEventLoop;
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 }
171
172
173
174 ::StatusCode AlgorithmTimerWrapper ::
175 endInputFile ()
176 {
177 using namespace msgEventLoop;
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 }
186}
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
clock_type::duration m_time_global
the timers for different calls
std::unique_ptr< IAlgorithmWrapper > m_algorithm
the actual algorithm
clock_type::duration m_time_event
clock_type::duration m_time_file
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
STL namespace.
all the external components an algorithm needs before initialization (in EventLoop)