ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoop
Root
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
13
#include <
EventLoop/AlgorithmTimerWrapper.h
>
14
15
#include <
EventLoop/MessageCheck.h
>
16
#include <
RootCoreUtils/Assert.h
>
17
#include <iomanip>
18
#include <ios>
19
#include <sstream>
20
21
//
22
// method implementations
23
//
24
25
namespace
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;
85
RCU_CHANGE_INVARIANT
(
this
);
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;
100
RCU_CHANGE_INVARIANT
(
this
);
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;
115
RCU_CHANGE_INVARIANT
(
this
);
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;
130
RCU_CHANGE_INVARIANT
(
this
);
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;
149
RCU_CHANGE_INVARIANT
(
this
);
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;
164
RCU_CHANGE_INVARIANT
(
this
);
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;
179
RCU_CHANGE_INVARIANT
(
this
);
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
}
AlgorithmTimerWrapper.h
Assert.h
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:219
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition
Assert.h:221
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:217
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
MessageCheck.h
EL::AlgorithmTimerWrapper::m_time_global
clock_type::duration m_time_global
the timers for different calls
Definition
AlgorithmTimerWrapper.h:85
EL::AlgorithmTimerWrapper::m_algorithm
std::unique_ptr< IAlgorithmWrapper > m_algorithm
the actual algorithm
Definition
AlgorithmTimerWrapper.h:82
EL::AlgorithmTimerWrapper::m_time_event
clock_type::duration m_time_event
Definition
AlgorithmTimerWrapper.h:87
EL::AlgorithmTimerWrapper::m_time_file
clock_type::duration m_time_file
Definition
AlgorithmTimerWrapper.h:86
EL::Algorithm
Definition
Algorithm.h:22
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
std
STL namespace.
str
Definition
BTagTrackIpAccessor.cxx:11
EL::AlgorithmWorkerData
all the external components an algorithm needs before initialization (in EventLoop)
Definition
AlgorithmWorkerData.h:34
Generated on
for ATLAS Offline Software by
1.17.0