The Gaudi Framework  v30r3 (a5ef0a68)
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 <fstream>
9 #include <functional>
10 #include <map>
11 #include <string>
12 // ============================================================================
13 // GaudiKernel
14 // ============================================================================
17 #include "GaudiKernel/Kernel.h"
18 #include "GaudiKernel/Service.h"
19 // ============================================================================
21 // ============================================================================
22 class ISvcLocator;
23 class IMessageSvc;
24 // ============================================================================
33 class ChronoStatSvc : public extends<Service, IChronoStatSvc, IIncidentListener>
34 {
35 public:
36  // ============================================================================
40  // ============================================================================
41 public:
42  // ============================================================================
44  StatusCode initialize() override;
46  StatusCode finalize() override;
47  // ============================================================================
48 public:
49  // ============================================================================
53  ChronoEntity* chronoStart( const IChronoStatSvc::ChronoTag& chronoTag ) override;
54  // ============================================================================
58  const ChronoEntity* chronoStop( const IChronoStatSvc::ChronoTag& chronoTag ) override;
59  // ============================================================================
63  IChronoStatSvc::ChronoTime chronoDelta( const IChronoStatSvc::ChronoTag& chronoTag,
64  IChronoStatSvc::ChronoType theType ) override;
65  // ============================================================================
69  void chronoPrint( const IChronoStatSvc::ChronoTag& chronoTag ) override;
70  // ============================================================================
74  ChronoStatus chronoStatus( const IChronoStatSvc::ChronoTag& chronoTag ) override;
75  // ============================================================================
80  void stat( const IChronoStatSvc::StatTag& statTag, const IChronoStatSvc::StatFlag& statFlag ) override;
81  // ============================================================================
86  void statPrint( const IChronoStatSvc::ChronoTag& statTag ) override;
87  // ============================================================================
93  const ChronoEntity* chrono( const IChronoStatSvc::ChronoTag& t ) const override;
94  // ============================================================================
100  StatEntity* stat( const IChronoStatSvc::StatTag& t ) override;
101  // ============================================================================
106  ChronoStatSvc( const std::string& name, ISvcLocator* svcloc );
108  void merge( const ChronoStatSvc& css );
109  // ============================================================================
110 
111 public:
112  void handle( const Incident& incident ) override;
113 
114 protected:
115  // ============================================================================
116  // print the "Stat" part of the ChronoStatSvc
117  void printStats();
118  // ============================================================================
119 private:
120  // ============================================================================
121  // default/copy constructor and assignment are disabled
122  ChronoStatSvc() = delete;
123  ChronoStatSvc( const ChronoStatSvc& ) = delete;
124  ChronoStatSvc& operator=( const ChronoStatSvc& ) = delete;
125  // ============================================================================
127  void saveStats();
128  // ============================================================================
129 private:
130  // ============================================================================
132  ChronoMap m_chronoEntities;
135 
137  StatMap m_statEntities;
140 
141  Gaudi::Property<bool> m_chronoTableFlag{this, "ChronoPrintOutTable", true,
142  "decide if the final printout should be performed"};
143  Gaudi::Property<bool> m_chronoCoutFlag{this, "ChronoDestinationCout", false,
144  "define the destination of the table to be printed"};
145  Gaudi::Property<int> m_intChronoPrintLevel{this, "ChronoPrintLevel", MSG::INFO, "print level"};
146  Gaudi::Property<bool> m_chronoOrderFlag{this, "ChronoTableToBeOrdered", true, "should the printout be ordered"};
147  Gaudi::Property<bool> m_printUserTime{this, "PrintUserTime", true};
148  Gaudi::Property<bool> m_printSystemTime{this, "PrintSystemTime", false};
149  Gaudi::Property<bool> m_printEllapsedTime{this, "PrintEllapsedTime", false};
150  Gaudi::Property<bool> m_statTableFlag{this, "StatPrintOutTable", true,
151  "decide if the final printout should be performed"};
152  Gaudi::Property<bool> m_statCoutFlag{this, "StatDestinationCout", false,
153  "define the destination of the table to be printed"};
154  Gaudi::Property<int> m_intStatPrintLevel{this, "StatPrintLevel", MSG::INFO, "print level"};
155  Gaudi::Property<bool> m_statOrderFlag{this, "StatTableToBeOrdered", true, "should the printout be ordered"};
156 
158  this, "AsciiStatsOutputFile", "",
159  "Name of the output file storing the stats. If empty, no statistics will be saved (default)"};
160 
162  this, "StatTableHeader",
163  " Counter | # | sum | mean/eff^* | rms/err^* | min | max |",
164  "The header row for the output Stat-table"};
165  Gaudi::Property<bool> m_useEffFormat{this, "UseEfficiencyRowFormat", true,
166  "Use the special format for printout of efficiency counters"};
167 
168  Gaudi::Property<std::string> m_perEventFile{this, "PerEventFile", "", "File name for per-event deltas"};
169 
171  TimeMap m_perEvtTime;
173 
174  // ============================================================================
175 };
176 // ============================================================================
177 // The END
178 // ============================================================================
179 #endif // GAUDISVC_CHRONOSTATSVC_H
180 // ============================================================================
Gaudi::Property< int > m_intStatPrintLevel
ChronoStatSvc & operator=(const ChronoStatSvc &)=delete
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
ChronoStatus chronoStatus(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStatus.
Gaudi::Property< std::string > m_header
Implementation of property with value of concrete type.
Definition: Property.h:381
StatMap m_statEntities
stat part
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
Gaudi::Property< bool > m_statCoutFlag
IChronoStatSvc::ChronoTime chronoDelta(const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType) override
Implementation of IchronoStatSvc::chronoDelta.
Gaudi::Property< bool > m_chronoOrderFlag
Gaudi::Property< bool > m_printUserTime
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.
std::map< IChronoStatSvc::ChronoTag, ChronoEntity > ChronoMap
some useful typedefs
Definition: ChronoStatSvc.h:38
void statPrint(const IChronoStatSvc::ChronoTag &statTag) override
prints (using message service) info about statistical entity, tagged by its name
STL class.
const ChronoEntity * chrono(const IChronoStatSvc::ChronoTag &t) const override
extract the chrono entity for the given tag (name)
STL class.
void merge(const ChronoStatSvc &css)
Compound assignment operator.
std::map< ChronoTag, std::vector< IChronoSvc::ChronoTime > > TimeMap
ChronoStatSvc()=delete
Gaudi::Property< bool > m_useEffFormat
void saveStats()
dump the statistics into an ASCII file for offline processing
Gaudi::Property< int > m_intChronoPrintLevel
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
TimeMap m_perEvtTime
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
const ChronoEntity * chronoStop(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStop.
Gaudi::Property< bool > m_statOrderFlag
Gaudi::Property< bool > m_chronoTableFlag
std::ofstream m_ofd
MSG::Level m_chronoPrintLevel
level of info printing
StatusCode initialize() override
Implementation of IService::initialize()
Gaudi::Property< bool > m_printEllapsedTime
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
void handle(const Incident &incident) override
Gaudi::Property< bool > m_statTableFlag
Base class for all Incidents (computing events).
Definition: Incident.h:17
ChronoEntity * chronoStart(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStart.
Gaudi::Property< std::string > m_statsOutFileName
MSG::Level m_statPrintLevel
level of info printing
Gaudi::Property< bool > m_chronoCoutFlag
backward compatible StatEntity class.
Definition: Counters.h:777
void chronoPrint(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoPrint.
std::map< IChronoStatSvc::StatTag, StatEntity > StatMap
Definition: ChronoStatSvc.h:39
The Chrono & Stat Sservice: service implements the IChronoStatSvc interface and provides the basic ch...
Definition: ChronoStatSvc.h:33
ChronoMap m_chronoEntities
chrono part
Gaudi::Property< bool > m_printSystemTime
StatusCode finalize() override
Implementation of IService::finalize()
Gaudi::Property< std::string > m_perEventFile