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"
19 // ============================================================================
21 // ============================================================================
22 class ISvcLocator ;
23 class IMessageSvc ;
24 // ============================================================================
33 class ChronoStatSvc: public extends<Service,
34  IChronoStatSvc,
35  IIncidentListener> {
36 public:
37  // ============================================================================
41  // ============================================================================
42 public:
43  // ============================================================================
45  StatusCode initialize() override;
47  StatusCode finalize() override;
48  // ============================================================================
49 public:
50  // ============================================================================
54  virtual ChronoEntity* chronoStart
55  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
56  // ============================================================================
60  virtual const ChronoEntity* chronoStop
61  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
62  // ============================================================================
66  virtual IChronoStatSvc::ChronoTime chronoDelta
67  ( const IChronoStatSvc::ChronoTag& chronoTag,
68  IChronoStatSvc::ChronoType theType ) override;
69  // ============================================================================
73  virtual void chronoPrint
74  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
75  // ============================================================================
79  virtual ChronoStatus chronoStatus
80  ( const IChronoStatSvc::ChronoTag& chronoTag ) override;
81  // ============================================================================
86  virtual void stat
87  ( const IChronoStatSvc::StatTag & statTag ,
88  const IChronoStatSvc::StatFlag & statFlag ) override;
89  // ============================================================================
94  virtual void statPrint
95  ( const IChronoStatSvc::ChronoTag& statTag) override;
96  // ============================================================================
102  virtual const ChronoEntity* chrono
103  ( const IChronoStatSvc::ChronoTag& t ) const override;
104  // ============================================================================
110  virtual const StatEntity* stat
111  ( const IChronoStatSvc::StatTag& t ) const override;
112  // ============================================================================
117  ChronoStatSvc ( const std::string& name, ISvcLocator* svcloc );
119  void merge ( const ChronoStatSvc& css);
121  ~ChronoStatSvc() override = default;
122  // ============================================================================
123 
124 public:
125  void handle(const Incident& incident) override;
126 
127 
128 protected:
129  // ============================================================================
130  // print the "Stat" part of the ChronoStatSvc
131  void printStats() ;
132  // ============================================================================
133 private:
134  // ============================================================================
135  // default/copy constructor and assignment are disabled
136  ChronoStatSvc() = delete;
137  ChronoStatSvc( const ChronoStatSvc& ) = delete;
138  ChronoStatSvc& operator=( const ChronoStatSvc& ) = delete;
139  // ============================================================================
141  void saveStats();
142  // ============================================================================
143 private:
144  // ============================================================================
146  ChronoMap m_chronoEntities;
162 
163  // property
165 
167  StatMap m_statEntities;
168 
179 
182 
183  // the header row
185  // format for regular statistical printout rows
187  // format for "efficiency" statistical printout rows
189  // flag to use the special "efficiency" format
190  bool m_useEffFormat = true ;
191 
193  TimeMap m_perEvtTime;
196 
197  // ============================================================================
198 };
199 // ============================================================================
200 // The END
201 // ============================================================================
202 #endif // GAUDISVC_CHRONOSTATSVC_H
203 // ============================================================================
204 
205 
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
STL class.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
STL class.
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:39
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:17
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:40
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)