21 #include "TDirectory.h" 26 using namespace Gaudi;
27 typedef const string&
CSTR;
29 #define S_OK StatusCode::SUCCESS 30 #define S_FAIL StatusCode::FAILURE 47 if ( !status.
isSuccess() )
return error(
"Failed to initialize Service base class." );
49 m_incidentSvc = service(
"IncidentSvc" );
50 if ( !m_incidentSvc )
return error(
"Unable to localize interface from service:IncidentSvc" );
52 m_incidentSvc->addListener(
this, IncidentType::BeginEvent, 1,
false,
false );
53 m_incidentSvc->addListener(
this,
"NEW_STREAM", 1,
false,
false );
54 m_incidentSvc->addListener(
this,
"CONNECTED_OUTPUT", 1,
false,
false );
56 if ( m_ioPerfStats.empty() )
return error(
"Performance monitoring file IOPerfStats was not defined." );
58 TDirectory::TContext ctxt(
nullptr );
59 m_perfFile.reset(
new TFile( m_ioPerfStats.value().c_str(),
"RECREATE" ) );
60 if ( !m_perfFile )
return error(
"Could not create ROOT file." );
62 if ( !( m_perfTree =
new TTree(
"T",
"performance measurement" ) ) )
return error(
"Could not create tree." );
64 m_perfTree->Branch(
"utime", &m_utime,
"utime/l" );
65 m_perfTree->Branch(
"stime", &m_stime,
"stime/l" );
66 m_perfTree->Branch(
"vsize", &m_vsize,
"vsize/l" );
67 m_perfTree->Branch(
"rss", &m_rss,
"rss/L" );
68 m_perfTree->Branch(
"time", &m_time,
"time/L" );
70 m_perfTree->Branch(
"event_number", &m_eventNumber,
"event_number/L" );
71 m_perfTree->Branch(
"event_type", &m_eventType,
"event_type/I" );
73 if ( m_setStreams.empty() ) m_setStreams =
"undefined";
74 if ( m_basketSize.empty() ) m_basketSize =
"undefined";
75 if ( m_bufferSize.empty() ) m_bufferSize =
"undefined";
76 if ( m_splitLevel.empty() ) m_splitLevel =
"undefined";
78 auto map =
new TMap();
79 map->Add(
new TObjString(
"streams" ),
new TObjString( m_setStreams.value().c_str() ) );
80 map->Add(
new TObjString(
"basket_size" ),
new TObjString( m_basketSize.value().c_str() ) );
81 map->Add(
new TObjString(
"buffer_size" ),
new TObjString( m_bufferSize.value().c_str() ) );
82 map->Add(
new TObjString(
"split_level" ),
new TObjString( m_splitLevel.value().c_str() ) );
83 map->Write(
"params", TObject::kSingleKey );
87 void RootPerfMonSvc::record(
EventType eventType ) {
89 m_eventType = eventType;
98 void RootPerfMonSvc::handle(
const Incident& incident ) {
100 if ( !t.
compare( IncidentType::BeginEvent ) ) {
105 if ( !t.
compare(
"CONNECTED_OUTPUT" ) ) { m_outputs.insert( incident.
source() ); }
112 auto map =
new TMap();
113 for (
const auto& i : m_outputs ) {
114 const char* fn = i.c_str();
115 Long_t id, siz, flags, tim;
116 if ( 0 == gSystem->GetPathInfo( fn, &
id, &siz, &flags, &tim ) ) {
118 map->Add(
new TObjString( fn ),
new TObjString( text ) );
121 TDirectory::TContext ctxt( m_perfFile.get() );
122 map->Write(
"Outputs", TObject::kSingleKey );
131 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.
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.