ChronoStatSvc.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_CHRONOSTATSVC_H__
2 #define GAUDISVC_CHRONOSTATSVC_H__
3 // ============================================================================
4 // include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <string>
9 #include <map>
10 #include <functional>
11 #include <fstream>
12 // ============================================================================
13 // GaudiKernel
14 // ============================================================================
15 #include "GaudiKernel/Kernel.h"
16 #include "GaudiKernel/Service.h"
17 #include "GaudiKernel/IChronoStatSvc.h"
18 #include "GaudiKernel/IIncidentListener.h"
19 // ============================================================================
21 // ============================================================================
22 class ISvcLocator ;
23 class IMessageSvc ;
24 // ============================================================================
33 class ChronoStatSvc: public extends2<Service, IChronoStatSvc,
34  IIncidentListener> {
35 public:
36  // ============================================================================
38  typedef std::map<IChronoStatSvc::ChronoTag,ChronoEntity> ChronoMap ;
39  typedef std::map<IChronoStatSvc::StatTag,StatEntity> StatMap ;
40  // ============================================================================
41 public:
42  // ============================================================================
44  StatusCode initialize() override;
46  StatusCode finalize() override;
47  // ============================================================================
48 public:
49  // ============================================================================
53  virtual ChronoEntity* chronoStart
54  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
55  // ============================================================================
59  virtual const ChronoEntity* chronoStop
60  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
61  // ============================================================================
65  virtual IChronoStatSvc::ChronoTime chronoDelta
66  ( const IChronoStatSvc::ChronoTag& chronoTag,
67  IChronoStatSvc::ChronoType theType ) override;
68  // ============================================================================
72  virtual void chronoPrint
73  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
74  // ============================================================================
78  virtual ChronoStatus chronoStatus
79  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
80  // ============================================================================
85  virtual void stat
86  ( const IChronoStatSvc::StatTag & statTag ,
87  const IChronoStatSvc::StatFlag & statFlag ) override;
88  // ============================================================================
93  virtual void statPrint
94  ( const IChronoStatSvc::ChronoTag& statTag) override;
95  // ============================================================================
101  virtual const ChronoEntity* chrono
102  ( const IChronoStatSvc::ChronoTag& t ) const override;
103  // ============================================================================
109  virtual const StatEntity* stat
110  ( const IChronoStatSvc::StatTag& t ) const override;
111  // ============================================================================
116  ChronoStatSvc ( const std::string& name, ISvcLocator* svcloc );
118  void merge ( const ChronoStatSvc& css);
120  ~ChronoStatSvc() override = default;
121  // ============================================================================
122 
123 public:
124  void handle(const Incident& incident) override;
125 
126 
127 protected:
128  // ============================================================================
129  // print the "Stat" part of the ChronoStatSvc
130  void printStats() ;
131  // ============================================================================
132 private:
133  // ============================================================================
134  // default/copy constructor and assignment are disabled
135  ChronoStatSvc() = delete;
136  ChronoStatSvc( const ChronoStatSvc& ) = delete;
137  ChronoStatSvc& operator=( const ChronoStatSvc& ) = delete;
138  // ============================================================================
140  void saveStats();
141  // ============================================================================
142 private:
143  // ============================================================================
145  ChronoMap m_chronoEntities;
161 
162  // property
164 
166  StatMap m_statEntities;
167 
178 
181 
182  // the header row
183  std::string m_header ;
184  // format for regular statistical printout rows
185  std::string m_format1 ;
186  // format for "efficiency" statistical printout rows
187  std::string m_format2 ;
188  // flag to use the special "efficiency" format
189  bool m_useEffFormat = true ;
190 
191  typedef std::map<ChronoTag, std::vector<IChronoSvc::ChronoTime> > TimeMap;
192  TimeMap m_perEvtTime;
193  std::string m_perEventFile;
194  std::ofstream m_ofd;
195 
196  // ============================================================================
197 };
198 // ============================================================================
199 // The END
200 // ============================================================================
201 #endif // GAUDISVC_CHRONOSTATSVC_H
202 // ============================================================================
203 
204 
ChronoStatSvc & operator=(const ChronoStatSvc &)=delete
bool m_useEffFormat
flag to use the special "efficiency" format
int m_intStatPrintLevel
level of info printing
bool m_chronoOrderFlag
flag for formattion the final statistic table
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
bool m_printUserTime
flag for printing User quantities
virtual ChronoStatus chronoStatus(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStatus.
StatMap m_statEntities
stat part
bool m_printEllapsedTime
flag for printing Ellapsed quantities
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
std::string m_header
the header row
virtual IChronoStatSvc::ChronoTime chronoDelta(const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType) override
Implementation of IchronoStatSvc::chronoDelta.
StringProperty m_statsOutFileName
Name of the output file where we'll dump the stats.
virtual void stat(const IChronoStatSvc::StatTag &statTag, const IChronoStatSvc::StatFlag &statFlag) override
Implementation of IChronoStatSvc::stat add statistical information to the entity , tagged by its name.
virtual void statPrint(const IChronoStatSvc::ChronoTag &statTag) override
prints (using message service) info about statistical entity, tagged by its name
long m_numberOfSkippedEventsForMemStat
std::string m_format2
format for "efficiency" statistical printout rows
bool m_chronoTableFlag
flag for printing the final table
int m_intChronoPrintLevel
level of info printing
void merge(const ChronoStatSvc &css)
Compound assignment operator.
std::map< ChronoTag, std::vector< IChronoSvc::ChronoTime > > TimeMap
ChronoStatSvc()=delete
void saveStats()
dump the statistics into an ASCII file for offline processing
bool m_statOrderFlag
flag for formattion the final statistic table
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
TimeMap m_perEvtTime
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
virtual const ChronoEntity * chronoStop(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStop.
~ChronoStatSvc() override=default
Destructor.
std::ofstream m_ofd
bool m_statTableFlag
flag for printing the final table
std::map< IChronoStatSvc::ChronoTag, ChronoEntity > ChronoMap
some useful typedefs
Definition: ChronoStatSvc.h:38
MSG::Level m_chronoPrintLevel
StatusCode initialize() override
Implementation of IService::initialize()
bool m_statCoutFlag
flag for destination of the t he final table
bool m_printSystemTime
flag for printing System quantities
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
void handle(const Incident &incident) override
Base class for all Incidents (computing events).
Definition: Incident.h:16
virtual ChronoEntity * chronoStart(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStart.
std::string m_perEventFile
MSG::Level m_statPrintLevel
bool m_chronoCoutFlag
flag for destination of the the final table
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64
virtual void chronoPrint(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoPrint.
std::string m_format1
format for regular statistical printout rows
The Chrono & Stat Sservice: service implements the IChronoStatSvc interface and provides the basic ch...
Definition: ChronoStatSvc.h:33
std::map< IChronoStatSvc::StatTag, StatEntity > StatMap
Definition: ChronoStatSvc.h:39
ChronoMap m_chronoEntities
chrono part
StatusCode finalize() override
Implementation of IService::finalize()
virtual const ChronoEntity * chrono(const IChronoStatSvc::ChronoTag &t) const override
extract the chrono entity for the given tag (name)