ATLAS Offline Software
StopwatchModule.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9 //
10 // includes
11 //
12 
14 
15 #include <EventLoop/ModuleData.h>
16 #include <RootCoreUtils/Assert.h>
17 #include <TList.h>
18 #include <TStopwatch.h>
19 
20 //
21 // method implementations
22 //
23 
24 namespace EL
25 {
26  namespace Detail
27  {
29  firstInitialize (ModuleData& /*data*/)
30  {
31  m_stopwatch = std::make_unique<TStopwatch> ();
32 
33  m_stopwatch->Start ();
34 
35  m_runTime = std::make_unique<TH1D> ("EventLoop_RunTime", "worker run-time summary", 5, 0, 5);
36  m_runTime->SetDirectory (nullptr);
37  m_runTime->Fill (0);
38  m_runTime->GetXaxis()->SetBinLabel (1, "jobs");
39  m_runTime->GetXaxis()->SetBinLabel (2, "files");
40  m_runTime->GetXaxis()->SetBinLabel (3, "events");
41  m_runTime->GetXaxis()->SetBinLabel (4, "cpu time");
42  m_runTime->GetXaxis()->SetBinLabel (5, "real time");
43  return ::StatusCode::SUCCESS;
44  }
45 
46 
47 
49  onFileExecute (ModuleData& /*data*/)
50  {
51  m_runTime->Fill (1);
52  return ::StatusCode::SUCCESS;
53  }
54 
55 
56 
59  {
60  m_stopwatch->Stop ();
61  m_runTime->Fill (2, data.m_eventsProcessed);
62  m_runTime->Fill (3, m_stopwatch->CpuTime());
63  m_runTime->Fill (4, m_stopwatch->RealTime());
64  m_stopwatch->Continue ();
65  data.addOutput (std::move (m_runTime));
66  return ::StatusCode::SUCCESS;
67  }
68 
69 
70 
72  onWorkerEnd (ModuleData& /*data*/)
73  {
74  m_stopwatch->Stop ();
75  m_stopwatch->Print ();
76  return ::StatusCode::SUCCESS;
77  }
78  }
79 }
EL::Detail::StopwatchModule::onFileExecute
virtual StatusCode onFileExecute(ModuleData &data) override
actions just before fileExecute is called on algorithms
Definition: StopwatchModule.cxx:49
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
EL::Detail::ModuleData
the data the EventLoop core classes are sharing with the Module implementation
Definition: ModuleData.h:64
EL::Detail::StopwatchModule::onWorkerEnd
virtual StatusCode onWorkerEnd(ModuleData &data) override
action at the end of the worker job
Definition: StopwatchModule.cxx:72
Assert.h
EL::Detail::StopwatchModule::postFinalize
virtual StatusCode postFinalize(ModuleData &data) override
actions after algorithms have been finalized
Definition: StopwatchModule.cxx:58
StopwatchModule.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EL::Detail::StopwatchModule::m_stopwatch
std::unique_ptr< TStopwatch > m_stopwatch
the stop watch we use for measuring total time spend
Definition: StopwatchModule.h:49
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::Detail::StopwatchModule::m_runTime
std::unique_ptr< TH1 > m_runTime
the run time summary histogram
Definition: StopwatchModule.h:45
xAOD::DiTauJetParameters::Detail
Detail
Definition: DiTauDefs.h:38
ModuleData.h
EL::Detail::StopwatchModule::firstInitialize
virtual StatusCode firstInitialize(ModuleData &data) override
action at the the very beginning of the worker job
Definition: StopwatchModule.cxx:29