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#include <sstream>
20
21//
22// method implementations
23//
24
25namespace EL
26{
27 void AlgorithmTimerWrapper ::
28 testInvariant () const
29 {
30 }
31
32
33
34 AlgorithmTimerWrapper ::
35 AlgorithmTimerWrapper (std::unique_ptr<IAlgorithmWrapper>&& val_algorithm)
36 : m_algorithm (std::move (val_algorithm))
37 {
38 RCU_NEW_INVARIANT (this);
39 }
40
41
42
43 std::string_view AlgorithmTimerWrapper ::
44 getName () const
45 {
46 RCU_READ_INVARIANT (this);
47 return m_algorithm->getName();
48 }
49
50
51
52 bool AlgorithmTimerWrapper ::
53 hasName (const std::string& name) const
54 {
55 RCU_READ_INVARIANT (this);
56 return m_algorithm->hasName (name);
57 }
58
59
60
61 std::unique_ptr<IAlgorithmWrapper> AlgorithmTimerWrapper ::
62 makeClone() const
63 {
64 using namespace msgEventLoop;
65 RCU_READ_INVARIANT (this);
66
67 return std::make_unique<AlgorithmTimerWrapper> (m_algorithm->makeClone());
68 }
69
70
71
72 Algorithm *AlgorithmTimerWrapper ::
73 getLegacyAlg ()
74 {
75 RCU_READ_INVARIANT (this);
76 return m_algorithm->getLegacyAlg();
77 }
78
79
80
81 StatusCode AlgorithmTimerWrapper ::
82 initialize (const AlgorithmWorkerData& workerData)
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();
90 m_time_global += stop - start;
91 return result;
92 }
93
94
95
96 StatusCode AlgorithmTimerWrapper ::
97 execute (const EventContext& ctx)
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();
105 m_time_event += stop - start;
106 return result;
107 }
108
109
110
111 StatusCode AlgorithmTimerWrapper ::
112 postExecute ()
113 {
114 using namespace msgEventLoop;
116
117 auto start = clock_type::now();
118 auto result = m_algorithm->postExecute ();
119 auto stop = clock_type::now();
120 m_time_event += stop - start;
121 return result;
122 }
123
124
125
126 StatusCode AlgorithmTimerWrapper ::
127 finalize ()
128 {
129 using namespace msgEventLoop;
131
132 auto start = clock_type::now();
133 auto result = m_algorithm->finalize ();
134 auto stop = clock_type::now();
135 m_time_global += stop - start;
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 }
142
143
144
145 ::StatusCode AlgorithmTimerWrapper ::
146 fileExecute ()
147 {
148 using namespace msgEventLoop;
150
151 auto start = clock_type::now();
152 auto result = m_algorithm->fileExecute ();
153 auto stop = clock_type::now();
154 m_time_file += stop - start;
155 return result;
156 }
157
158
159
160 ::StatusCode AlgorithmTimerWrapper ::
161 beginInputFile ()
162 {
163 using namespace msgEventLoop;
165
166 auto start = clock_type::now();
167 auto result = m_algorithm->beginInputFile ();
168 auto stop = clock_type::now();
169 m_time_file += stop - start;
170 return result;
171 }
172
173
174
175 ::StatusCode AlgorithmTimerWrapper ::
176 endInputFile ()
177 {
178 using namespace msgEventLoop;
180
181 auto start = clock_type::now();
182 auto result = m_algorithm->endInputFile ();
183 auto stop = clock_type::now();
184 m_time_file += stop - start;
185 return result;
186 }
187}
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:219
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217
#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)