11#include <framework/core/ModuleStatistics.h>
12#include <framework/pcore/Mergeable.h>
13#include <framework/core/Module.h>
102 const std::vector<Belle2::ModuleStatistics>* modules =
nullptr,
bool html =
false)
const;
108 const std::vector<Belle2::ModuleStatistics>&
getAll()
const {
return m_stats; }
169 void write_csv(
const char* filename =
"ProcessStatistics.csv")
const;
178 virtual void clear()
override;
181 virtual TObject*
Clone(
const char* newname =
"")
const override;
206 double startTime = 0,
double startMemory = 0);
209 std::vector<Belle2::ModuleStatistics>
m_stats;
Abstract base class for objects that can be merged.
Keep track of time and memory consumption during processing.
void add(EStatisticCounters type, value_type time, value_type memory)
Add a time and memory measurment to the counter of a given type.
EStatisticCounters
Enum to define all counter types.
@ c_Event
Counting time/calls in event()
@ c_DontCollectStatistics
No statistics is collected for this module.
Class to collect call statistics for all modules.
void setCounters(double &time, double &memory, double startTime=0, double startMemory=0)
Set counters time and memory to contain the current clock value and memory consumption respectively.
ModuleStatistics m_global
Statistics object for global time and memory consumption.
void stopGlobal(ModuleStatistics::EStatisticCounters type)
Stop global timer and add values to the statistic counter.
const ModuleStatistics & getGlobal() const
Get global statistics.
const std::vector< Belle2::ModuleStatistics > & getAll() const
Get entire statistics map.
ProcessStatistics()
Constructor.
void appendUnmergedModules(const ProcessStatistics *otherObject)
Merge dissimilar objects (mainly loading ProcessStatistics from file).
double m_globalTime
store clock counter for global time consumption
ModuleStatistics & getStatistics(const Module *module)
Get statistics for single module.
std::string getStatisticsString(ModuleStatistics::EStatisticCounters type=ModuleStatistics::c_Event, const std::vector< Belle2::ModuleStatistics > *modules=nullptr, bool html=false) const
Return string with statistics for all modules.
void startModule()
Start module timer.
int getIndex(const Module *module)
get m_stats index for given module, inserting it if not found.
double m_suspendedMemory
(transient)
void initModule(const Module *module)
Init module statistics: Set name from module if still empty and remember initialization index for dis...
virtual void merge(const Mergeable *other) override
Merge other ProcessStatistics object into this one.
std::map< const Module *, int > m_modulesToStatsIndex
transient, maps Module* to m_stats index.
ClassDefOverride(ProcessStatistics, 2)
(transient)
virtual TObject * Clone(const char *newname="") const override
Reimplement TObject::Clone() since we also need m_modulesToStatsIndex.
void suspendGlobal()
Suspend timer for global measurement, needed for newRun.
void stopModule(const Module *module, ModuleStatistics::EStatisticCounters type)
Stop module counter and attribute values to appropriate module.
ProcessStatistics(const ProcessStatistics &)=default
Hide copy constructor.
void write_csv(const char *filename="ProcessStatistics.csv") const
Write process statistics to a csv file.
std::string getInfoHTML() const
Return a short summary of this object's contents in HTML format.
std::vector< Belle2::ModuleStatistics > m_stats
module statistics
double m_suspendedTime
(transient)
double m_moduleTime
(transient)
void startGlobal()
Start timer for global measurement.
virtual void clear() override
Clear collected statistics but keep names of modules.
double m_globalMemory
(transient)
double m_moduleMemory
(transient)
ProcessStatistics & operator=(ProcessStatistics &)
Prohibit assignment operator.
void setTransientCounters(const ProcessStatistics *otherObject)
Set transient counters from otherObject.
void resumeGlobal()
Resume timer after call to suspendGlobal()
Abstract base class for different kinds of events.