20 #include "TDirectory.h" 26 using namespace Gaudi;
27 typedef const string&
CSTR;
29 #define S_OK StatusCode::SUCCESS 30 #define S_FAIL StatusCode::FAILURE 48 return error(
"Failed to initialize Service base class.");
50 m_incidentSvc = service(
"IncidentSvc");
52 return error(
"Unable to localize interface from service:IncidentSvc");
54 m_incidentSvc->addListener(
this, IncidentType::BeginEvent, 1,
false,
false);
55 m_incidentSvc->addListener(
this,
"NEW_STREAM", 1,
false,
false);
56 m_incidentSvc->addListener(
this,
"CONNECTED_OUTPUT", 1,
false,
false);
58 if (m_ioPerfStats.empty())
59 return error(
"Performance monitoring file IOPerfStats was not defined.");
61 TDirectory::TContext ctxt(
nullptr);
62 m_perfFile.reset(
new TFile(m_ioPerfStats.value().c_str(),
"RECREATE") );
63 if (!m_perfFile )
return error(
"Could not create ROOT file.");
65 if (!(m_perfTree =
new TTree(
"T",
"performance measurement")))
66 return error(
"Could not create tree.");
68 m_perfTree->Branch(
"utime", &m_utime,
"utime/l");
69 m_perfTree->Branch(
"stime", &m_stime,
"stime/l");
70 m_perfTree->Branch(
"vsize", &m_vsize,
"vsize/l");
71 m_perfTree->Branch(
"rss", &m_rss,
"rss/L");
72 m_perfTree->Branch(
"time", &m_time,
"time/L");
74 m_perfTree->Branch(
"event_number", &m_eventNumber,
"event_number/L");
75 m_perfTree->Branch(
"event_type", &m_eventType,
"event_type/I");
77 if (m_setStreams.empty())
78 m_setStreams =
"undefined";
79 if (m_basketSize.empty())
80 m_basketSize =
"undefined";
81 if (m_bufferSize.empty())
82 m_bufferSize =
"undefined";
83 if (m_splitLevel.empty())
84 m_splitLevel =
"undefined";
86 auto map =
new TMap();
87 map->Add(
new TObjString(
"streams"),
new TObjString(m_setStreams.value().c_str()));
88 map->Add(
new TObjString(
"basket_size"),
new TObjString(m_basketSize.value().c_str()));
89 map->Add(
new TObjString(
"buffer_size"),
new TObjString(m_bufferSize.value().c_str()));
90 map->Add(
new TObjString(
"split_level"),
new TObjString(m_splitLevel.value().c_str()));
91 map->Write(
"params", TObject::kSingleKey);
97 m_eventType = eventType;
98 m_utime = (ULong_t)data.
utime;
99 m_stime = (ULong_t)data.
stime;
100 m_vsize = (ULong_t)data.
vsize;
101 m_rss = (Long_t)data.
rss;
102 m_time = (Long_t)data.
time;
106 void RootPerfMonSvc::handle(
const Incident& incident) {
108 if ( !t.
compare(IncidentType::BeginEvent) ) {
113 if ( !t.
compare(
"CONNECTED_OUTPUT") ) {
114 m_outputs.insert(incident.
source());
122 auto map =
new TMap();
123 for(
const auto &i : m_outputs) {
124 const char* fn = i.c_str();
125 Long_t id, siz, flags, tim;
126 if ( 0 == gSystem->GetPathInfo(fn,&
id,&siz,&flags,&tim) ) {
128 map->Add(
new TObjString(fn),
new TObjString(text));
131 TDirectory::TContext ctxt(m_perfFile.get());
132 map->Write(
"Outputs", TObject::kSingleKey);
141 m_incidentSvc.reset();
Definition of the MsgStream class used to transmit messages.
StatusCode initialize() override
const std::string & type() const
Access to the incident type.
StatusCode finalize() override
const std::string & source() const
Access to the source of the incident.
bool isSuccess() const
Test for a status code of SUCCESS.
This class is used for returning status codes from appropriate routines.
Base class for all Incidents (computing events).
Helper functions to set/get the application return code.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.